-
Notifications
You must be signed in to change notification settings - Fork 2.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Back-forward cache: Restoring focus #5878
Comments
I don't have much of substance to add, but I will say that this seems like a nice and small interop bug we could fix, compared to all the other scary bfcache business :). I hope we can get implementers to chime in. I'm ambivalent myself between "focus is kept all the time" vs. "focus was lost, but it's back again". Maybe there are other similar features affected by bfcache which we could compare with? |
Slightly related: WICG/portals#257 |
Various folks discussed this today in the triage meeting (#6371). The Mozilla and Google representatives present thought that between the Firefox and Safari behavior, the Safari was probably best. Although nobody felt too strongly, the idea of firing less events (and thus running less script) during page unload and load pushed us in that direction. This might be what the spec already says; in particular I can't find anything that changes the focused area of the document, or runs focusing or unfocusing steps, on navigation (including bfcache navigation). However, it's possible the focus fixup rule applies upon navigations, if elements in navigated-away-from-documents are not "being rendered"... but I'm unsure. That might be worth investigating. So, I think the action items here are:
|
Fixes whatwg#5878. Clarifies that the focused element stays the same/not reset when a document's "full active" state changed, and no events (focus/blur) are fired
Thanks @domenic! I looked into "being rendered" & "fully active" a while back, and found that "being rendered" is still true for non-fully active documents. I've sent a PR at #6696 to add notes as you suggested, and @hiroshige-g will upload a WPT PR soon! |
yeah, we generally don't want to fire events during moving pages in & out of the back-forward cache so sticking to Safari/WebKit's behavior is desirable here unless there are some web compatibility issues or use cases that can't be addressed with that approach. |
Bug: 1107415, whatwg/html#5878 Change-Id: I2bb9a420de19f24d7010917f7e6ce54cba8212fb
Bug: 1107415, whatwg/html#5878 Change-Id: I2bb9a420de19f24d7010917f7e6ce54cba8212fb
Uploaded WPT web-platform-tests/wpt#31084, confirming the behavior described at #5878 (comment) (passing on Safari, failing on Chromium/Firefox). |
Bug: 1107415, whatwg/html#5878 Change-Id: I2bb9a420de19f24d7010917f7e6ce54cba8212fb
Fixes #5878. Clarifies that the focused element stays the same and is not reset when a document's fully active state is changed, and no events (focus/blur) are fired. Also clarifies that fully active does not impact "being rendered" or viewport intersection.
Bug: 1107415, 1253728, whatwg/html#5878 Change-Id: I2bb9a420de19f24d7010917f7e6ce54cba8212fb
This CL adds a test to confirm that, when page gets into and out of BFCache, - Focus should be kept and - blur/focus events are not fired. The current results are Safari: Pass Firefox: Focus remains the same but blur/focus events are fired. Chrome: Focus is lost. See whatwg/html#6696 for other status and implementation bug links etc. Bug: 1107415, 1253728, whatwg/html#5878 Change-Id: I2bb9a420de19f24d7010917f7e6ce54cba8212fb
Are there any issues tracking restoring focus for back/forward navigations to in-document fragments? Related: https://bugs.chromium.org/p/chromium/issues/detail?id=1275230 |
Fixes whatwg#5878. Clarifies that the focused element stays the same and is not reset when a document's fully active state is changed, and no events (focus/blur) are fired. Also clarifies that fully active does not impact "being rendered" or viewport intersection.
I opened #7397 to track my previous question. |
This CL adds a test to confirm that, when page gets into and out of BFCache, - Focus should be kept and - blur/focus events are not fired. The current results are Safari: Pass Firefox: Focus remains the same but blur/focus events are fired. Chrome: Focus is lost. See whatwg/html#6696 for other status and implementation bug links etc. Bug: 1107415, 1253728, whatwg/html#5878 Change-Id: I2bb9a420de19f24d7010917f7e6ce54cba8212fb
This CL adds a test to confirm that, when page gets into and out of BFCache, - Focus should be kept and - blur/focus events are not fired. The current results are Safari: Pass Firefox: Focus remains the same but blur/focus events are fired. Chrome: Focus is lost. See whatwg/html#6696 for other status and implementation bug links etc. Bug: 1107415, 1253728, whatwg/html#5878 Change-Id: I2bb9a420de19f24d7010917f7e6ce54cba8212fb
This CL adds a test to confirm that, when page gets into and out of BFCache, - Focus should be kept and - blur/focus events are not fired. The current results are Safari: Pass Firefox: Focus remains the same but blur/focus events are fired. Chrome: Focus is lost. See whatwg/html#6696 for other status and implementation bug links etc. Bug: 1107415, 1253728, whatwg/html#5878 Change-Id: I2bb9a420de19f24d7010917f7e6ce54cba8212fb
This CL adds a test to confirm that, when page gets into and out of BFCache, - Focus should be kept and - blur/focus events are not fired. The current results are Safari: Pass Firefox: Focus remains the same but blur/focus events are fired. Chrome: Focus is lost. See whatwg/html#6696 for other status and implementation bug links etc. Bug: 1107415, 1253728, whatwg/html#5878 Change-Id: I2bb9a420de19f24d7010917f7e6ce54cba8212fb
This CL adds a test to confirm that, when page gets into and out of BFCache, - Focus should be kept and - blur/focus events are not fired. The current results are Safari: Pass Firefox: Focus remains the same but blur/focus events are fired. Chrome: Focus is lost. See whatwg/html#6696 for other status and implementation bug links etc. Bug: 1107415, 1253728, whatwg/html#5878 Change-Id: I2bb9a420de19f24d7010917f7e6ce54cba8212fb Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3198456 Reviewed-by: Rakina Zata Amni <rakina@chromium.org> Commit-Queue: Hiroshige Hayashizaki <hiroshige@chromium.org> Cr-Commit-Position: refs/heads/main@{#968703}
This CL adds a test to confirm that, when page gets into and out of BFCache, - Focus should be kept and - blur/focus events are not fired. The current results are Safari: Pass Firefox: Focus remains the same but blur/focus events are fired. Chrome: Focus is lost. See whatwg/html#6696 for other status and implementation bug links etc. Bug: 1107415, 1253728, whatwg/html#5878 Change-Id: I2bb9a420de19f24d7010917f7e6ce54cba8212fb Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3198456 Reviewed-by: Rakina Zata Amni <rakina@chromium.org> Commit-Queue: Hiroshige Hayashizaki <hiroshige@chromium.org> Cr-Commit-Position: refs/heads/main@{#968703}
This CL adds a test to confirm that, when page gets into and out of BFCache, - Focus should be kept and - blur/focus events are not fired. The current results are Safari: Pass Firefox: Focus remains the same but blur/focus events are fired. Chrome: Focus is lost. See whatwg/html#6696 for other status and implementation bug links etc. Bug: 1107415, 1253728, whatwg/html#5878 Change-Id: I2bb9a420de19f24d7010917f7e6ce54cba8212fb Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3198456 Reviewed-by: Rakina Zata Amni <rakina@chromium.org> Commit-Queue: Hiroshige Hayashizaki <hiroshige@chromium.org> Cr-Commit-Position: refs/heads/main@{#968703}
This CL adds a test to confirm that, when page gets into and out of BFCache, - Focus should be kept and - blur/focus events are not fired. The current results are Safari: Pass Firefox: Focus remains the same but blur/focus events are fired. Chrome: Focus is lost. See whatwg/html#6696 for other status and implementation bug links etc. Bug: 1107415, 1253728, whatwg/html#5878 Change-Id: I2bb9a420de19f24d7010917f7e6ce54cba8212fb Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3198456 Reviewed-by: Rakina Zata Amni <rakina@chromium.org> Commit-Queue: Hiroshige Hayashizaki <hiroshige@chromium.org> Cr-Commit-Position: refs/heads/main@{#968703}
…nd BFCache, a=testonly Automatic update from web-platform-tests [WPT] BFCache: focus should be kept around BFCache This CL adds a test to confirm that, when page gets into and out of BFCache, - Focus should be kept and - blur/focus events are not fired. The current results are Safari: Pass Firefox: Focus remains the same but blur/focus events are fired. Chrome: Focus is lost. See whatwg/html#6696 for other status and implementation bug links etc. Bug: 1107415, 1253728, whatwg/html#5878 Change-Id: I2bb9a420de19f24d7010917f7e6ce54cba8212fb Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3198456 Reviewed-by: Rakina Zata Amni <rakina@chromium.org> Commit-Queue: Hiroshige Hayashizaki <hiroshige@chromium.org> Cr-Commit-Position: refs/heads/main@{#968703} -- wpt-commits: a1e49a05bf46345316fd04bb4b22e5e7e8d9bc70 wpt-pr: 31084
This CL adds a test to confirm that, when page gets into and out of BFCache, - Focus should be kept and - blur/focus events are not fired. The current results are Safari: Pass Firefox: Focus remains the same but blur/focus events are fired. Chrome: Focus is lost. See whatwg/html#6696 for other status and implementation bug links etc. Bug: 1107415, 1253728, whatwg/html#5878 Change-Id: I2bb9a420de19f24d7010917f7e6ce54cba8212fb Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3198456 Reviewed-by: Rakina Zata Amni <rakina@chromium.org> Commit-Queue: Hiroshige Hayashizaki <hiroshige@chromium.org> Cr-Commit-Position: refs/heads/main@{#968703}
…nd BFCache, a=testonly Automatic update from web-platform-tests [WPT] BFCache: focus should be kept around BFCache This CL adds a test to confirm that, when page gets into and out of BFCache, - Focus should be kept and - blur/focus events are not fired. The current results are Safari: Pass Firefox: Focus remains the same but blur/focus events are fired. Chrome: Focus is lost. See whatwg/html#6696 for other status and implementation bug links etc. Bug: 1107415, 1253728, whatwg/html#5878 Change-Id: I2bb9a420de19f24d7010917f7e6ce54cba8212fb Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3198456 Reviewed-by: Rakina Zata Amni <rakina@chromium.org> Commit-Queue: Hiroshige Hayashizaki <hiroshige@chromium.org> Cr-Commit-Position: refs/heads/main@{#968703} -- wpt-commits: a1e49a05bf46345316fd04bb4b22e5e7e8d9bc70 wpt-pr: 31084
…nd BFCache, a=testonly Automatic update from web-platform-tests [WPT] BFCache: focus should be kept around BFCache This CL adds a test to confirm that, when page gets into and out of BFCache, - Focus should be kept and - blur/focus events are not fired. The current results are Safari: Pass Firefox: Focus remains the same but blur/focus events are fired. Chrome: Focus is lost. See whatwg/html#6696 for other status and implementation bug links etc. Bug: 1107415, 1253728, whatwg/html#5878 Change-Id: I2bb9a420de19f24d7010917f7e6ce54cba8212fb Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3198456 Reviewed-by: Rakina Zata Amni <rakina@chromium.org> Commit-Queue: Hiroshige Hayashizaki <hiroshige@chromium.org> Cr-Commit-Position: refs/heads/main@{#968703} -- wpt-commits: a1e49a05bf46345316fd04bb4b22e5e7e8d9bc70 wpt-pr: 31084
…nd BFCache, a=testonly Automatic update from web-platform-tests [WPT] BFCache: focus should be kept around BFCache This CL adds a test to confirm that, when page gets into and out of BFCache, - Focus should be kept and - blur/focus events are not fired. The current results are Safari: Pass Firefox: Focus remains the same but blur/focus events are fired. Chrome: Focus is lost. See whatwg/html#6696 for other status and implementation bug links etc. Bug: 1107415, 1253728, whatwg/html#5878 Change-Id: I2bb9a420de19f24d7010917f7e6ce54cba8212fb Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3198456 Reviewed-by: Rakina Zata Amni <rakina@chromium.org> Commit-Queue: Hiroshige Hayashizaki <hiroshige@chromium.org> Cr-Commit-Position: refs/heads/main@{#968703} -- wpt-commits: a1e49a05bf46345316fd04bb4b22e5e7e8d9bc70 wpt-pr: 31084
Fixes whatwg#5878. Clarifies that the focused element stays the same and is not reset when a document's fully active state is changed, and no events (focus/blur) are fired. Also clarifies that fully active does not impact "being rendered" or viewport intersection.
This CL adds a test to confirm that, when page gets into and out of BFCache, - Focus should be kept and - blur/focus events are not fired. The current results are Safari: Pass Firefox: Focus remains the same but blur/focus events are fired. Chrome: Focus is lost. See whatwg/html#6696 for other status and implementation bug links etc. Bug: 1107415, 1253728, whatwg/html#5878 Change-Id: I2bb9a420de19f24d7010917f7e6ce54cba8212fb Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3198456 Reviewed-by: Rakina Zata Amni <rakina@chromium.org> Commit-Queue: Hiroshige Hayashizaki <hiroshige@chromium.org> Cr-Commit-Position: refs/heads/main@{#968703} NOKEYCHECK=True GitOrigin-RevId: 60349a6da0ccfa946936e76665ccff67fc9eac22
It looks like focus works differently with bfcache in Safari, Firefox, and Chrome (thanks @tkent-google for noticing!)
If we navigate away from a page that has a focused element (e.g. submitting a text-input form), and we go back & restore it from bfcache (tester page) :
blur
event is never fired. Thefocus
event is only fired when the element initially gets focused.blur
event is fired afterpagehide
(when navigating away) but before pageshow (when navigating back). Thefocus
event is fired for the second time afterpageshow
.blur
event fired beforepagehide
), and won't be focused again when we navigate back.I think it would be ideal to restore the focused element when navigating back (like Safari & Firefox is currently doing), but I'm not sure whether it should be "focus is kept all this time" (so no
blur
event should be fired), or "focus was lost, but it's back again" (so we fireblur
when navigating away, then firefocus
when navigating back). Maybe the latter makes more sense as the entire document/page is no longer in focus after we navigate away from it.The text was updated successfully, but these errors were encountered: