Skip to content

Commit c8e0dd9

Browse files
committed
fix: scroll to first invalid field when attempting to save overlay widget
1 parent 148a43b commit c8e0dd9

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

src/gui/app/directives/modals/overlay/add-or-edit-overlay-widget-modal.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -299,9 +299,24 @@
299299
true
300300
);
301301

302+
$ctrl.scrollToFirstInvalidField = () => {
303+
const invalidField = document.querySelector('.modal-body .ng-invalid[name]:not(form)');
304+
if (invalidField) {
305+
invalidField.scrollIntoView({ behavior: 'smooth', block: 'center' });
306+
307+
// Focus the field if it's focusable
308+
setTimeout(() => {
309+
if (invalidField.focus) {
310+
invalidField.focus();
311+
}
312+
}, 300);
313+
}
314+
};
315+
302316
$ctrl.save = () => {
303317
$scope.widgetSettings.$setSubmitted();
304318
if ($scope.widgetSettings.$invalid) {
319+
$ctrl.scrollToFirstInvalidField();
305320
return;
306321
}
307322

0 commit comments

Comments
 (0)