fix(theme): add validation editing content

pull/2328/head
viniciusteixeiradias 3 years ago
parent 8e139c3a3b
commit a73524433d

@ -54,6 +54,25 @@ const preconnect = () => {
})
}
const isEditingContent = (event: KeyboardEvent): boolean => {
const element = event.target as HTMLElement;
const tagName = element.tagName;
return (
element.isContentEditable ||
tagName === 'INPUT' ||
tagName === 'SELECT' ||
tagName === 'TEXTAREA'
);
}
const isHotKey = (e: KeyboardEvent): boolean => {
const isBindKey = e.key === 'k' && (e.ctrlKey || e.metaKey)
const isSlashKey = e.key === '/'
return isBindKey || isSlashKey
}
onMounted(() => {
if (!__ALGOLIA__) {
return
@ -62,10 +81,7 @@ onMounted(() => {
preconnect()
const handleSearchHotKey = (e: KeyboardEvent) => {
const isHotKeyBind = e.key === 'k' && (e.ctrlKey || e.metaKey)
const isSlashKey = e.key === '/'
if (!isSlashKey && !isHotKeyBind) {
if (isEditingContent(e) || !isHotKey(e)) {
return
}

Loading…
Cancel
Save