fix(editor): Do not show hover tooltip when autocomplete is active (#11653)

This commit is contained in:
Elias Meire 2024-11-11 18:15:11 +01:00 committed by GitHub
parent 4dbf2f4256
commit 23caf43e30
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 20 additions and 0 deletions

View file

@ -242,6 +242,9 @@ export const hoverTooltipSource = (view: EditorView, pos: number) => {
const state = view.state.field(cursorInfoBoxTooltip, false); const state = view.state.field(cursorInfoBoxTooltip, false);
const cursorTooltipOpen = !!state?.tooltip; const cursorTooltipOpen = !!state?.tooltip;
// Don't show hover tooltips when autocomplete is active
if (completionStatus(view.state) === 'active') return null;
const jsNodeResult = getJsNodeAtPosition(view.state, pos); const jsNodeResult = getJsNodeAtPosition(view.state, pos);
if (!jsNodeResult) { if (!jsNodeResult) {

View file

@ -6,6 +6,16 @@ import { n8nLang } from '@/plugins/codemirror/n8nLang';
import { hoverTooltipSource, infoBoxTooltips } from './InfoBoxTooltip'; import { hoverTooltipSource, infoBoxTooltips } from './InfoBoxTooltip';
import * as utils from '@/plugins/codemirror/completions/utils'; import * as utils from '@/plugins/codemirror/completions/utils';
import * as workflowHelpers from '@/composables/useWorkflowHelpers'; import * as workflowHelpers from '@/composables/useWorkflowHelpers';
import { completionStatus } from '@codemirror/autocomplete';
vi.mock('@codemirror/autocomplete', async (importOriginal) => {
const actual = await importOriginal<{}>();
return {
...actual,
completionStatus: vi.fn(() => null),
};
});
describe('Infobox tooltips', () => { describe('Infobox tooltips', () => {
beforeEach(() => { beforeEach(() => {
@ -99,6 +109,13 @@ describe('Infobox tooltips', () => {
expect(tooltip).not.toBeNull(); expect(tooltip).not.toBeNull();
expect(infoBoxHeader(tooltip?.view)).toHaveTextContent('includes(searchString, start?)'); expect(infoBoxHeader(tooltip?.view)).toHaveTextContent('includes(searchString, start?)');
}); });
test('should not show a tooltip when autocomplete is open', () => {
vi.spyOn(workflowHelpers, 'resolveParameter').mockReturnValue('foo');
vi.mocked(completionStatus).mockReturnValue('active');
const tooltip = hoverTooltip('{{ $json.str.includ|es() }}');
expect(tooltip).toBeNull();
});
}); });
}); });