mirror of
https://github.com/n8n-io/n8n.git
synced 2024-12-25 04:34:06 -08:00
fix(editor): Do not show hover tooltip when autocomplete is active (#11653)
This commit is contained in:
parent
4dbf2f4256
commit
23caf43e30
|
@ -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) {
|
||||||
|
|
|
@ -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();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue