diff --git a/superset-frontend/src/dashboard/components/SliceAdder.tsx b/superset-frontend/src/dashboard/components/SliceAdder.tsx index f6c176d9bf8..7475d005e00 100644 --- a/superset-frontend/src/dashboard/components/SliceAdder.tsx +++ b/superset-frontend/src/dashboard/components/SliceAdder.tsx @@ -260,6 +260,13 @@ function SliceAdder({ [fetchSlices, searchUpdated, sortBy, userIdForFetch], ); + useEffect( + () => () => { + handleChange.cancel(); + }, + [handleChange], + ); + const handleSelect = useCallback( (newSortBy: keyof Slice) => { setSortBy(newSortBy); diff --git a/superset-frontend/src/dashboard/components/UndoRedoKeyListeners/index.tsx b/superset-frontend/src/dashboard/components/UndoRedoKeyListeners/index.tsx index 7417dcdbf63..81b5f3127e3 100644 --- a/superset-frontend/src/dashboard/components/UndoRedoKeyListeners/index.tsx +++ b/superset-frontend/src/dashboard/components/UndoRedoKeyListeners/index.tsx @@ -29,8 +29,9 @@ function UndoRedoKeyListeners({ onUndo, onRedo }: UndoRedoKeyListenersProps) { (event: KeyboardEvent) => { const controlOrCommand = event.ctrlKey || event.metaKey; if (controlOrCommand) { - const isZChar = event.key === 'z' || event.keyCode === 90; - const isYChar = event.key === 'y' || event.keyCode === 89; + const key = event.key.toLowerCase(); + const isUndo = key === 'z' && !event.shiftKey; + const isRedo = key === 'y' || (key === 'z' && event.shiftKey); const isEditingMarkdown = document?.querySelector( '.dashboard-markdown--editing', ); @@ -38,9 +39,9 @@ function UndoRedoKeyListeners({ onUndo, onRedo }: UndoRedoKeyListenersProps) { '.editable-title--editing', ); - if (!isEditingMarkdown && !isEditingTitle && (isZChar || isYChar)) { + if (!isEditingMarkdown && !isEditingTitle && (isUndo || isRedo)) { event.preventDefault(); - const func = isZChar ? onUndo : onRedo; + const func = isUndo ? onUndo : onRedo; func(); } }