File tree 2 files changed +37
-1
lines changed
librustdoc/html/static/js
2 files changed +37
-1
lines changed Original file line number Diff line number Diff line change @@ -897,7 +897,15 @@ function loadCss(cssUrl) {
897
897
! elemIsInParent ( document . activeElement , window . CURRENT_NOTABLE_ELEMENT . NOTABLE_BASE ) &&
898
898
! elemIsInParent ( event . relatedTarget , window . CURRENT_NOTABLE_ELEMENT . NOTABLE_BASE )
899
899
) {
900
- hideNotable ( ) ;
900
+ // Work around a difference in the focus behaviour between Firefox, Chrome, and Safari.
901
+ // When I click the button on an already-opened notable trait popover, Safari
902
+ // hides the popover and then immediately shows it again, while everyone else hides it
903
+ // and it stays hidden.
904
+ //
905
+ // To work around this, make sure the click finishes being dispatched before
906
+ // hiding the popover. Since `hideNotable()` is idempotent, this makes Safari behave
907
+ // consistently with the other two.
908
+ setTimeout ( hideNotable , 0 ) ;
901
909
}
902
910
}
903
911
Original file line number Diff line number Diff line change @@ -199,3 +199,31 @@ call-function: (
199
199
"trait_color": "rgb(110, 79, 201)",
200
200
},
201
201
)
202
+
203
+ reload:
204
+
205
+ // Check that pressing escape works
206
+ click: "//*[@id='method.create_an_iterator_from_read']//*[@class='notable-traits']"
207
+ move-cursor-to: "//*[@class='notable popover']"
208
+ assert-count: ("//*[@class='notable popover']", 1)
209
+ press-key: "Escape"
210
+ assert-count: ("//*[@class='notable popover']", 0)
211
+
212
+ // Check that clicking outside works.
213
+ click: "//*[@id='method.create_an_iterator_from_read']//*[@class='notable-traits']"
214
+ assert-count: ("//*[@class='notable popover']", 1)
215
+ click: ".search-input"
216
+ assert-count: ("//*[@class='notable popover']", 0)
217
+
218
+ // Check that pressing tab over and over works.
219
+ click: "//*[@id='method.create_an_iterator_from_read']//*[@class='notable-traits']"
220
+ move-cursor-to: "//*[@class='notable popover']"
221
+ assert-count: ("//*[@class='notable popover']", 1)
222
+ press-key: "Tab"
223
+ press-key: "Tab"
224
+ press-key: "Tab"
225
+ press-key: "Tab"
226
+ press-key: "Tab"
227
+ press-key: "Tab"
228
+ press-key: "Tab"
229
+ assert-count: ("//*[@class='notable popover']", 0)
You can’t perform that action at this time.
0 commit comments