fix(editor): Fix NDV output tabs resetting on any click (#8808)

This commit is contained in:
Elias Meire 2024-03-05 15:45:41 +01:00 committed by GitHub
parent cdec7c9334
commit c7c17673cb
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 28 additions and 6 deletions

View file

@ -149,9 +149,9 @@ export default defineComponent({
this.isFocused = false; this.isFocused = false;
if (wasFocused) {
this.$emit('blur'); this.$emit('blur');
if (wasFocused) {
const telemetryPayload = createExpressionTelemetryPayload( const telemetryPayload = createExpressionTelemetryPayload(
this.segments, this.segments,
this.modelValue, this.modelValue,

View file

@ -595,7 +595,7 @@ import { useNDVStore } from '@/stores/ndv.store';
import { useNodeTypesStore } from '@/stores/nodeTypes.store'; import { useNodeTypesStore } from '@/stores/nodeTypes.store';
import { useNodeHelpers } from '@/composables/useNodeHelpers'; import { useNodeHelpers } from '@/composables/useNodeHelpers';
import { useToast } from '@/composables/useToast'; import { useToast } from '@/composables/useToast';
import { isObject } from 'lodash-es'; import { isEqual, isObject } from 'lodash-es';
import { useExternalHooks } from '@/composables/useExternalHooks'; import { useExternalHooks } from '@/composables/useExternalHooks';
import { useSourceControlStore } from '@/stores/sourceControl.store'; import { useSourceControlStore } from '@/stores/sourceControl.store';
import RunDataPinButton from '@/components/RunDataPinButton.vue'; import RunDataPinButton from '@/components/RunDataPinButton.vue';
@ -1473,7 +1473,8 @@ export default defineComponent({
}, },
}, },
watch: { watch: {
node() { node(newNode: INodeUi, prevNode: INodeUi) {
if (newNode.id === prevNode.id) return;
this.init(); this.init();
}, },
hasNodeRun() { hasNodeRun() {
@ -1491,9 +1492,10 @@ export default defineComponent({
immediate: true, immediate: true,
deep: true, deep: true,
}, },
jsonData(value: IDataObject[]) { jsonData(data: IDataObject[], prevData: IDataObject[]) {
if (isEqual(data, prevData)) return;
this.refreshDataSize(); this.refreshDataSize();
this.showPinDataDiscoveryTooltip(value); this.showPinDataDiscoveryTooltip(data);
}, },
binaryData(newData: IBinaryKeyData[], prevData: IBinaryKeyData[]) { binaryData(newData: IBinaryKeyData[], prevData: IBinaryKeyData[]) {
if (newData.length && !prevData.length && this.displayMode !== 'binary') { if (newData.length && !prevData.length && this.displayMode !== 'binary') {

View file

@ -33,4 +33,24 @@ describe('ExpressionParameterInput', () => {
await userEvent.click(getByTestId('expander')); await userEvent.click(getByTestId('expander'));
expect(emitted().modalOpenerClick).toEqual(expected); expect(emitted().modalOpenerClick).toEqual(expected);
}); });
test('it should only emit blur when input had focus', async () => {
const { getByTestId, emitted, baseElement } = renderComponent({
props: {
modelValue: '={{$json.foo}}',
},
});
// trigger click outside -> blur
await userEvent.click(baseElement);
expect(emitted('blur')).toBeUndefined();
// focus expression editor
await userEvent.click(
getByTestId('inline-expression-editor-input').querySelector('.cm-line') as Element,
);
// trigger click outside -> blur
await userEvent.click(baseElement);
expect(emitted('blur')).toHaveLength(1);
});
}); });