mirror of
https://github.com/sky-systems/sky_phone.git
synced 2026-09-04 09:13:24 +00:00
FIX - allow movement outside phone text fields (#14)
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
const nonTextInputTypes = new Set([
|
||||
'button',
|
||||
'checkbox',
|
||||
'color',
|
||||
'file',
|
||||
'hidden',
|
||||
'image',
|
||||
'radio',
|
||||
'range',
|
||||
'reset',
|
||||
'submit',
|
||||
])
|
||||
|
||||
type FocusableElement = Pick<
|
||||
HTMLElement,
|
||||
'getAttribute' | 'isContentEditable' | 'tagName'
|
||||
>
|
||||
|
||||
export function isTextInputElement(element: FocusableElement): boolean {
|
||||
if (
|
||||
element.getAttribute('readonly') !== null ||
|
||||
element.getAttribute('aria-readonly') === 'true'
|
||||
) {
|
||||
return false
|
||||
}
|
||||
if (element.isContentEditable || element.getAttribute('role') === 'textbox') {
|
||||
return true
|
||||
}
|
||||
if (element.tagName === 'TEXTAREA') return true
|
||||
if (element.tagName !== 'INPUT') return false
|
||||
|
||||
const inputType = element.getAttribute('type')?.toLowerCase() ?? 'text'
|
||||
return !nonTextInputTypes.has(inputType)
|
||||
}
|
||||
Reference in New Issue
Block a user