Skip to content

Commit f070fe2

Browse files
committed
Auto-focus next field
1 parent 6e5341d commit f070fe2

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

frontend/public/scripts.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,12 @@ function next() {
134134
} else {
135135
document.getElementById('back')?.classList.remove('hidden');
136136
};
137+
// focus first input of the new step
138+
const newField = document.querySelector(`.inputField[step="${step}"]`);
139+
if (newField) {
140+
const input = newField.querySelector('input, textarea, select');
141+
if (input) input.focus();
142+
};
137143
};
138144

139145
function back() {
@@ -153,6 +159,12 @@ function back() {
153159
document.getElementById('back')?.classList.remove('hidden');
154160
};
155161
document.getElementById('create')?.classList.add('hidden');
162+
// focus first input of the new step
163+
const newField = document.querySelector(`.inputField[step="${step}"]`);
164+
if (newField) {
165+
const input = newField.querySelector('input, textarea, select');
166+
if (input) input.focus();
167+
};
156168
};
157169

158170
function saveChange(key, value) {

0 commit comments

Comments
 (0)