-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(context-menu): add flag for disable context menu
- Loading branch information
Showing
7 changed files
with
67 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { useTranslation } from 'next-i18next'; | ||
import { useCallback, useEffect } from 'react'; | ||
|
||
import { useExperienceFlagsStore } from '@/lib/state/experience_flags'; | ||
|
||
const useContextMenu = () => { | ||
const { t } = useTranslation('common'); | ||
const isDisabled = useExperienceFlagsStore( | ||
(state) => state.disableContextMenu, | ||
); | ||
const handleContextMenu = useCallback( | ||
(e: MouseEvent) => { | ||
e.preventDefault(); | ||
alert(t('contextMenu.disabled')); | ||
}, | ||
[t], | ||
); | ||
|
||
useEffect(() => { | ||
if (!isDisabled) return; | ||
|
||
document.addEventListener('contextmenu', handleContextMenu); | ||
|
||
return () => document.removeEventListener('contextmenu', handleContextMenu); | ||
}, [handleContextMenu, isDisabled]); | ||
}; | ||
|
||
export default useContextMenu; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { default as useContextMenu } from './hooks/useContextMenu'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters