fix: clear codacy focus and history highs
This commit is contained in:
@@ -36,11 +36,11 @@ function buildSortItems(locale: AppLocale, customProperties?: string[]): SortIte
|
||||
}
|
||||
|
||||
function resolveFocusedIndex(groupLabel: string, current: SortOption, sortItems: SortItem[]) {
|
||||
const activeElement = document.activeElement
|
||||
if (activeElement instanceof HTMLElement) {
|
||||
const activeIndexText = activeElement.dataset.sortItemIndex
|
||||
const activeHTMLElement = document.activeElement
|
||||
if (activeHTMLElement instanceof HTMLElement) {
|
||||
const activeIndexText = activeHTMLElement.dataset.sortItemIndex
|
||||
const activeIndex = activeIndexText === undefined ? -1 : Number(activeIndexText)
|
||||
if (activeElement.dataset.sortGroupLabel === groupLabel && activeIndex >= 0) return activeIndex
|
||||
if (activeHTMLElement.dataset.sortGroupLabel === groupLabel && activeIndex >= 0) return activeIndex
|
||||
}
|
||||
|
||||
const currentIndex = sortItems.findIndex((item) => item.value === current)
|
||||
|
||||
@@ -400,13 +400,13 @@ export function useNoteListSort({
|
||||
|
||||
// --- useMultiSelectKeyboard ---
|
||||
|
||||
function isInputFocused(): boolean {
|
||||
const activeElement = document.activeElement
|
||||
if (!(activeElement instanceof HTMLElement)) return false
|
||||
function isInputHtmlElementFocused(): boolean {
|
||||
const activeHTMLElement = document.activeElement
|
||||
if (!(activeHTMLElement instanceof HTMLElement)) return false
|
||||
|
||||
return activeElement.tagName === 'INPUT'
|
||||
|| activeElement.tagName === 'TEXTAREA'
|
||||
|| activeElement.isContentEditable
|
||||
return activeHTMLElement.tagName === 'INPUT'
|
||||
|| activeHTMLElement.tagName === 'TEXTAREA'
|
||||
|| activeHTMLElement.isContentEditable
|
||||
}
|
||||
|
||||
function handleEscapeKey(e: KeyboardEvent, multiSelect: MultiSelectState) {
|
||||
@@ -416,7 +416,7 @@ function handleEscapeKey(e: KeyboardEvent, multiSelect: MultiSelectState) {
|
||||
}
|
||||
|
||||
function handleSelectAllKey(e: KeyboardEvent, multiSelect: MultiSelectState, isEntityView: boolean) {
|
||||
if (e.key !== 'a' || !(e.metaKey || e.ctrlKey) || isEntityView || isInputFocused()) return
|
||||
if (e.key !== 'a' || !(e.metaKey || e.ctrlKey) || isEntityView || isInputHtmlElementFocused()) return
|
||||
e.preventDefault()
|
||||
multiSelect.selectAll()
|
||||
}
|
||||
|
||||
@@ -9,13 +9,13 @@ interface UseMultiSelectKeyboardOptions {
|
||||
enableActionShortcuts?: boolean
|
||||
}
|
||||
|
||||
function isInputFocused(): boolean {
|
||||
const activeElement = document.activeElement
|
||||
if (!(activeElement instanceof HTMLElement)) return false
|
||||
function isInputHtmlElementFocused(): boolean {
|
||||
const activeHTMLElement = document.activeElement
|
||||
if (!(activeHTMLElement instanceof HTMLElement)) return false
|
||||
|
||||
return activeElement.tagName === 'INPUT'
|
||||
|| activeElement.tagName === 'TEXTAREA'
|
||||
|| activeElement.isContentEditable
|
||||
return activeHTMLElement.tagName === 'INPUT'
|
||||
|| activeHTMLElement.tagName === 'TEXTAREA'
|
||||
|| activeHTMLElement.isContentEditable
|
||||
}
|
||||
|
||||
function usesCommandModifier(event: KeyboardEvent): boolean {
|
||||
@@ -29,7 +29,7 @@ function clearSelectionOnEscape(event: KeyboardEvent, multiSelect: MultiSelectSt
|
||||
}
|
||||
|
||||
function selectVisibleNotes(event: KeyboardEvent, multiSelect: MultiSelectState, isEntityView: boolean) {
|
||||
if (event.key !== 'a' || !(event.metaKey || event.ctrlKey) || isEntityView || isInputFocused()) return
|
||||
if (event.key !== 'a' || !(event.metaKey || event.ctrlKey) || isEntityView || isInputHtmlElementFocused()) return
|
||||
event.preventDefault()
|
||||
multiSelect.selectAll()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user