File tree Expand file tree Collapse file tree 3 files changed +33
-11
lines changed Expand file tree Collapse file tree 3 files changed +33
-11
lines changed Original file line number Diff line number Diff line change @@ -428,7 +428,7 @@ class LinkHintsMode {
428
428
if ( hasPopoverSupport ) {
429
429
this . containerEl . popover = "manual" ;
430
430
this . containerEl . showPopover ( ) ;
431
- this . containerEl . classList . add ( "vimiumPopover " ) ;
431
+ this . containerEl . classList . add ( "vimium-popover " ) ;
432
432
}
433
433
434
434
this . setIndicator ( ) ;
Original file line number Diff line number Diff line change @@ -196,14 +196,14 @@ iframe.vimium-hud-frame {
196
196
opacity : 0 ;
197
197
}
198
198
199
- . vimiumPopover {
200
- top : 0 !important ;
201
- left : 0 !important ;
202
- position : absolute !important ;
203
- display : block !important ;
204
- width : 100% !important ;
205
- height : 100% !important ;
206
- overflow : visible !important ;
199
+ div . vimium-popover {
200
+ top : 0 ;
201
+ left : 0 ;
202
+ position : absolute;
203
+ display : block;
204
+ width : 100% ;
205
+ height : 100% ;
206
+ overflow : visible;
207
207
}
208
208
209
209
body .vimium-find-mode ::selection {
Original file line number Diff line number Diff line change @@ -243,12 +243,34 @@ const OptionsPage = {
243
243
return result ;
244
244
} ,
245
245
246
+ isElementInView ( element ) {
247
+ const rect = element . getBoundingClientRect ( ) ;
248
+ return (
249
+ rect . top >= 0 &&
250
+ rect . left >= 0 &&
251
+ rect . bottom <= ( window . innerHeight || document . documentElement . clientHeight ) &&
252
+ rect . right <= ( window . innerWidth || document . documentElement . clientWidth )
253
+ ) ;
254
+ } ,
255
+
246
256
async saveOptions ( ) {
257
+ // If no fields with validation errors are in view, scroll one of them into view
258
+ // so it's clear what the issue is.
259
+
247
260
const hasErrors = this . showValidationErrors ( ) ;
248
261
if ( hasErrors ) {
249
- const error = document . querySelector ( ".validation-error" ) ;
262
+ const errors = Array . from ( document . querySelectorAll ( ".validation-error" ) ) ;
250
263
251
- error ?. scrollIntoView ( ) ;
264
+ let isAnyElementInView = errors . some ( ( element ) => this . isElementInView ( element ) == true ) ;
265
+
266
+ if ( isAnyElementInView ) {
267
+ return ;
268
+ }
269
+
270
+ errors [ 0 ] ?. scrollIntoView ( {
271
+ behavior : "smooth" ,
272
+ block : "start" ,
273
+ } ) ;
252
274
253
275
return ;
254
276
}
You can’t perform that action at this time.
0 commit comments