fix: next input area is now selected via a css query
This commit is contained in:
parent
2450e03173
commit
1aaf254c3c
@ -1,7 +1,7 @@
|
|||||||
import { Utility } from '../../core/utility';
|
import { Utility } from '../../core/utility';
|
||||||
|
|
||||||
const ENTER_IS_TAB_INITIALIZED_CLASS = 'enter-as-tab--initialized';
|
const ENTER_IS_TAB_INITIALIZED_CLASS = 'enter-as-tab--initialized';
|
||||||
const FORM_GROUP_INPUT_ID = 'hident29';
|
const AREA_SELECTOR = 'input, textarea';
|
||||||
|
|
||||||
@Utility({
|
@Utility({
|
||||||
selector: '[uw-enter-as-tab]',
|
selector: '[uw-enter-as-tab]',
|
||||||
@ -30,8 +30,19 @@ export class EnterIsTab {
|
|||||||
this._element.addEventListener('keypress', (e) => {
|
this._element.addEventListener('keypress', (e) => {
|
||||||
if(e.key === 'Enter') {
|
if(e.key === 'Enter') {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
let messageArea = document.getElementById(FORM_GROUP_INPUT_ID);
|
let currentInputFieldId = this._element.id;
|
||||||
messageArea.focus();
|
let inputAreas = document.querySelectorAll(AREA_SELECTOR);
|
||||||
|
let nextInputArea = null;
|
||||||
|
for (let i = 0; i < inputAreas.length; i++) {
|
||||||
|
if(inputAreas[i].id === currentInputFieldId) {
|
||||||
|
nextInputArea = inputAreas[i+1];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(nextInputArea) {
|
||||||
|
nextInputArea.focus();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user