Removed prev and next element finding errors

pull/5323/head
tugcekucukoglu 2024-02-22 12:19:35 +03:00
parent d05395dc54
commit e3ff6a13b0
2 changed files with 13 additions and 5 deletions

View File

@ -92,7 +92,7 @@ export default {
});
},
moveToPrev(event) {
var prevInput = this.findPrevInput(event.target);
let prevInput = this.findPrevInput(event.target);
if (prevInput) {
prevInput.focus();
@ -100,7 +100,7 @@ export default {
}
},
moveToNext(event) {
var nextInput = this.findNextInput(event.target);
let nextInput = this.findNextInput(event.target);
if (nextInput) {
nextInput.focus();
@ -108,12 +108,16 @@ export default {
}
},
findNextInput(element) {
var nextElement = element.nextElementSibling;
let nextElement = element.nextElementSibling;
if (!nextElement) return;
return nextElement.nodeName === 'INPUT' ? nextElement : this.findNextInput(nextElement);
},
findPrevInput(element) {
var prevElement = element.previousElementSibling;
let prevElement = element.previousElementSibling;
if (!prevElement) return;
return prevElement.nodeName === 'INPUT' ? prevElement : this.findPrevInput(prevElement);
},

View File

@ -23,7 +23,11 @@
</tr>
<tr>
<td><i>left arrow</i></td>
<td>Moves focus to the next previous element.</td>
<td>Moves focus to the previous input element.</td>
</tr>
<tr>
<td><i>backspace</i></td>
<td>Deletes the input and moves focus to the previous input element.</td>
</tr>
</tbody>
</table>