fix: Fixes issue where preferences view would not close after pressing Escape
This commit is contained in:
@@ -189,6 +189,7 @@ export class KeyboardService {
|
||||
this.commandHandlers.push(observer)
|
||||
|
||||
const thislessObservers = this.commandHandlers
|
||||
console.log(thislessObservers)
|
||||
return () => {
|
||||
observer.onKeyDown = undefined
|
||||
observer.onKeyDown = undefined
|
||||
|
||||
@@ -6,7 +6,6 @@ import PreferencesCanvas from './PreferencesCanvas'
|
||||
import { PreferencesProps } from './PreferencesProps'
|
||||
import { useDisableBodyScrollOnMobile } from '@/Hooks/useDisableBodyScrollOnMobile'
|
||||
import { useAndroidBackHandler } from '@/NativeMobileWeb/useAndroidBackHandler'
|
||||
import { ESCAPE_COMMAND } from '@standardnotes/ui-services'
|
||||
import Modal from '../Modal/Modal'
|
||||
import { classNames } from '@standardnotes/snjs'
|
||||
import { isIOS } from '@/Utils'
|
||||
@@ -25,17 +24,7 @@ const PreferencesView: FunctionComponent<PreferencesProps> = ({
|
||||
|
||||
useEffect(() => {
|
||||
menu.selectPane(viewControllerManager.preferencesController.currentPane)
|
||||
const removeEscKeyObserver = application.keyboardService.addCommandHandler({
|
||||
command: ESCAPE_COMMAND,
|
||||
onKeyDown: (event) => {
|
||||
event.preventDefault()
|
||||
closePreferences()
|
||||
},
|
||||
})
|
||||
return () => {
|
||||
removeEscKeyObserver()
|
||||
}
|
||||
}, [menu, viewControllerManager.preferencesController.currentPane, application.keyboardService, closePreferences])
|
||||
}, [menu, viewControllerManager.preferencesController.currentPane])
|
||||
|
||||
useDisableBodyScrollOnMobile()
|
||||
|
||||
|
||||
@@ -20,7 +20,11 @@ const PreferencesViewWrapper: FunctionComponent<PreferencesViewWrapperProps> = (
|
||||
}, [commandService, viewControllerManager])
|
||||
|
||||
return (
|
||||
<ModalOverlay isOpen={viewControllerManager.preferencesController?.isOpen} className="p-0">
|
||||
<ModalOverlay
|
||||
isOpen={viewControllerManager.preferencesController.isOpen}
|
||||
onDismiss={viewControllerManager.preferencesController.closePreferences}
|
||||
className="p-0"
|
||||
>
|
||||
<PreferencesView
|
||||
closePreferences={() => viewControllerManager.preferencesController.closePreferences()}
|
||||
application={application}
|
||||
|
||||
Reference in New Issue
Block a user