chore: display options menu keyboard nav

This commit is contained in:
Aman Harwara
2023-04-29 00:10:13 +05:30
parent 0ab9006c52
commit e1a47ea884
6 changed files with 28 additions and 16 deletions

View File

@@ -29,6 +29,7 @@ import { setFloatingElemPosition } from '../../Lexical/Utils/setFloatingElemPosi
import { LexicalPencilFill } from '@standardnotes/icons'
import { IconComponent } from '../../Lexical/../Lexical/Theme/IconComponent'
import { getDOMRangeRect } from '../../Lexical/Utils/getDOMRangeRect'
import { KeyboardKey } from '@standardnotes/ui-services'
function FloatingLinkEditor({ editor, anchorElem }: { editor: LexicalEditor; anchorElem: HTMLElement }): JSX.Element {
const editorRef = useRef<HTMLDivElement | null>(null)
@@ -148,7 +149,7 @@ function FloatingLinkEditor({ editor, anchorElem }: { editor: LexicalEditor; anc
setLinkUrl(event.target.value)
}}
onKeyDown={(event) => {
if (event.key === 'Enter') {
if (event.key === KeyboardKey.Enter) {
event.preventDefault()
if (lastSelection !== null) {
if (linkUrl !== '') {
@@ -156,7 +157,7 @@ function FloatingLinkEditor({ editor, anchorElem }: { editor: LexicalEditor; anc
}
setEditMode(false)
}
} else if (event.key === 'Escape') {
} else if (event.key === KeyboardKey.Escape) {
event.preventDefault()
setEditMode(false)
}

View File

@@ -5,6 +5,7 @@ import { TranslateFromTopAnimation, TranslateToTopAnimation } from '@/Constants/
import { useLifecycleAnimation } from '@/Hooks/useLifecycleAnimation'
import { ArrowDownIcon, ArrowUpIcon, CloseIcon, ArrowRightIcon } from '@standardnotes/icons'
import {
KeyboardKey,
keyboardStringForShortcut,
SUPER_SEARCH_TOGGLE_CASE_SENSITIVE,
SUPER_SEARCH_TOGGLE_REPLACE_MODE,
@@ -71,7 +72,7 @@ export const SearchDialog = ({ open, closeDialog }: { open: boolean; closeDialog
<div
className="flex flex-col gap-2 py-2 px-2"
onKeyDown={(event) => {
if (event.key === 'Escape') {
if (event.key === KeyboardKey.Escape) {
closeDialog()
}
}}