Remove hotkey scope from useListenClickOutside (#11098)
The old `useListenClickOutside` API allowed us to pass a hotkeyScope as a parameter, the click outside was triggered only if the current hotkey scope matched the parameter. We don't want this anymore. This fixes a few bugs related to hotkey scopes inside the side panel.
This commit is contained in:
@ -22,7 +22,6 @@ import { RecordFilterGroupsComponentInstanceContext } from '@/object-record/reco
|
|||||||
import { RecordFiltersComponentInstanceContext } from '@/object-record/record-filter/states/context/RecordFiltersComponentInstanceContext';
|
import { RecordFiltersComponentInstanceContext } from '@/object-record/record-filter/states/context/RecordFiltersComponentInstanceContext';
|
||||||
import { RecordSortsComponentInstanceContext } from '@/object-record/record-sort/states/context/RecordSortsComponentInstanceContext';
|
import { RecordSortsComponentInstanceContext } from '@/object-record/record-sort/states/context/RecordSortsComponentInstanceContext';
|
||||||
import { getRecordIndexIdFromObjectNamePluralAndViewId } from '@/object-record/utils/getRecordIndexIdFromObjectNamePluralAndViewId';
|
import { getRecordIndexIdFromObjectNamePluralAndViewId } from '@/object-record/utils/getRecordIndexIdFromObjectNamePluralAndViewId';
|
||||||
import { AppHotkeyScope } from '@/ui/utilities/hotkey/types/AppHotkeyScope';
|
|
||||||
import { useListenClickOutside } from '@/ui/utilities/pointer-event/hooks/useListenClickOutside';
|
import { useListenClickOutside } from '@/ui/utilities/pointer-event/hooks/useListenClickOutside';
|
||||||
import { useRecoilComponentValueV2 } from '@/ui/utilities/state/component-state/hooks/useRecoilComponentValueV2';
|
import { useRecoilComponentValueV2 } from '@/ui/utilities/state/component-state/hooks/useRecoilComponentValueV2';
|
||||||
import { useIsFeatureEnabled } from '@/workspace/hooks/useIsFeatureEnabled';
|
import { useIsFeatureEnabled } from '@/workspace/hooks/useIsFeatureEnabled';
|
||||||
@ -70,7 +69,6 @@ export const CommandMenuContainer = ({
|
|||||||
refs: [commandMenuRef],
|
refs: [commandMenuRef],
|
||||||
callback: closeCommandMenu,
|
callback: closeCommandMenu,
|
||||||
listenerId: 'COMMAND_MENU_LISTENER_ID',
|
listenerId: 'COMMAND_MENU_LISTENER_ID',
|
||||||
hotkeyScope: AppHotkeyScope.CommandMenuOpen,
|
|
||||||
excludeClassNames: ['page-header-command-menu-button'],
|
excludeClassNames: ['page-header-command-menu-button'],
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@ -1,7 +1,6 @@
|
|||||||
import React, { useEffect } from 'react';
|
import React, { useEffect } from 'react';
|
||||||
import { useRecoilCallback } from 'recoil';
|
import { useRecoilCallback } from 'recoil';
|
||||||
|
|
||||||
import { internalHotkeysEnabledScopesState } from '@/ui/utilities/hotkey/states/internal/internalHotkeysEnabledScopesState';
|
|
||||||
import { useClickOustideListenerStates } from '@/ui/utilities/pointer-event/hooks/useClickOustideListenerStates';
|
import { useClickOustideListenerStates } from '@/ui/utilities/pointer-event/hooks/useClickOustideListenerStates';
|
||||||
|
|
||||||
const CLICK_OUTSIDE_DEBUG_MODE = false;
|
const CLICK_OUTSIDE_DEBUG_MODE = false;
|
||||||
@ -17,7 +16,6 @@ export type ClickOutsideListenerProps<T extends Element> = {
|
|||||||
callback: (event: MouseEvent | TouchEvent) => void;
|
callback: (event: MouseEvent | TouchEvent) => void;
|
||||||
mode?: ClickOutsideMode;
|
mode?: ClickOutsideMode;
|
||||||
listenerId: string;
|
listenerId: string;
|
||||||
hotkeyScope?: string;
|
|
||||||
enabled?: boolean;
|
enabled?: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -27,7 +25,6 @@ export const useListenClickOutside = <T extends Element>({
|
|||||||
callback,
|
callback,
|
||||||
mode = ClickOutsideMode.compareHTMLRef,
|
mode = ClickOutsideMode.compareHTMLRef,
|
||||||
listenerId,
|
listenerId,
|
||||||
hotkeyScope,
|
|
||||||
enabled = true,
|
enabled = true,
|
||||||
}: ClickOutsideListenerProps<T>) => {
|
}: ClickOutsideListenerProps<T>) => {
|
||||||
const {
|
const {
|
||||||
@ -45,18 +42,7 @@ export const useListenClickOutside = <T extends Element>({
|
|||||||
|
|
||||||
set(getClickOutsideListenerMouseDownHappenedState, true);
|
set(getClickOutsideListenerMouseDownHappenedState, true);
|
||||||
|
|
||||||
const currentHotkeyScopes = snapshot
|
const isListening = clickOutsideListenerIsActivated && enabled;
|
||||||
.getLoadable(internalHotkeysEnabledScopesState)
|
|
||||||
.getValue();
|
|
||||||
|
|
||||||
const isListeningBasedOnHotkeyScope = hotkeyScope
|
|
||||||
? currentHotkeyScopes.includes(hotkeyScope)
|
|
||||||
: true;
|
|
||||||
|
|
||||||
const isListening =
|
|
||||||
clickOutsideListenerIsActivated &&
|
|
||||||
enabled &&
|
|
||||||
isListeningBasedOnHotkeyScope;
|
|
||||||
|
|
||||||
if (!isListening) {
|
if (!isListening) {
|
||||||
return;
|
return;
|
||||||
@ -121,7 +107,6 @@ export const useListenClickOutside = <T extends Element>({
|
|||||||
[
|
[
|
||||||
getClickOutsideListenerIsActivatedState,
|
getClickOutsideListenerIsActivatedState,
|
||||||
getClickOutsideListenerMouseDownHappenedState,
|
getClickOutsideListenerMouseDownHappenedState,
|
||||||
hotkeyScope,
|
|
||||||
enabled,
|
enabled,
|
||||||
mode,
|
mode,
|
||||||
refs,
|
refs,
|
||||||
@ -136,18 +121,7 @@ export const useListenClickOutside = <T extends Element>({
|
|||||||
.getLoadable(getClickOutsideListenerIsActivatedState)
|
.getLoadable(getClickOutsideListenerIsActivatedState)
|
||||||
.getValue();
|
.getValue();
|
||||||
|
|
||||||
const currentHotkeyScopes = snapshot
|
const isListening = clickOutsideListenerIsActivated && enabled;
|
||||||
.getLoadable(internalHotkeysEnabledScopesState)
|
|
||||||
.getValue();
|
|
||||||
|
|
||||||
const isListeningBasedOnHotkeyScope = hotkeyScope
|
|
||||||
? currentHotkeyScopes.includes(hotkeyScope)
|
|
||||||
: true;
|
|
||||||
|
|
||||||
const isListening =
|
|
||||||
clickOutsideListenerIsActivated &&
|
|
||||||
enabled &&
|
|
||||||
isListeningBasedOnHotkeyScope;
|
|
||||||
|
|
||||||
const isMouseDownInside = snapshot
|
const isMouseDownInside = snapshot
|
||||||
.getLoadable(getClickOutsideListenerIsMouseDownInsideState)
|
.getLoadable(getClickOutsideListenerIsMouseDownInsideState)
|
||||||
@ -241,7 +215,6 @@ export const useListenClickOutside = <T extends Element>({
|
|||||||
isListening,
|
isListening,
|
||||||
hasMouseDownHappened,
|
hasMouseDownHappened,
|
||||||
isClickedOnExcluded,
|
isClickedOnExcluded,
|
||||||
hotkeyScope,
|
|
||||||
enabled,
|
enabled,
|
||||||
event,
|
event,
|
||||||
});
|
});
|
||||||
@ -254,7 +227,6 @@ export const useListenClickOutside = <T extends Element>({
|
|||||||
},
|
},
|
||||||
[
|
[
|
||||||
getClickOutsideListenerIsActivatedState,
|
getClickOutsideListenerIsActivatedState,
|
||||||
hotkeyScope,
|
|
||||||
enabled,
|
enabled,
|
||||||
getClickOutsideListenerIsMouseDownInsideState,
|
getClickOutsideListenerIsMouseDownInsideState,
|
||||||
getClickOutsideListenerMouseDownHappenedState,
|
getClickOutsideListenerMouseDownHappenedState,
|
||||||
|
|||||||
Reference in New Issue
Block a user