Closed (fixed)
Project:
Drupal core
Version:
9.4.x-dev
Component:
Olivero theme
Priority:
Major
Category:
Bug report
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
15 Mar 2022 at 17:46 UTC
Updated:
9 Apr 2022 at 16:59 UTC
Jump to comment: Most recent, Most recent file

Comments
Comment #2
mherchelComment #3
andy-blumThis is a major problem, and IMO is 100% a bad implementation by the webkit team that causes non-standard behavior on the web. Unfortunately based on my research it seems unlikely to be fixed in webkit any time soon and there are a couple of issues remaining here.
A potential solution would be to refactor the Search block to render
<a href="/search">{{icon}}</a>and then re-render a button element over top of that and wiring up the dropdown functionality.Comment #4
mherchelI really disagree with this. If we go this route we'll be generating a whole bunch of untestable code (since our test bots don't run in Safari). The closing of the search form is triggered by JS, so a JS solution is appropriate IMO.
Looking into this further, the search form isn't even available in Safari when JS is disabled because the
:focus-withinnever gets activated when the user clicks on the button to open it. This is a separate issue though and much less critical.Comment #5
andy-blumTabbing over the search icon opens the drop-down though
Comment #6
andy-blum@mherchel a less radical alternative is to listen for 'pointerdown'. Those events fire prior to focus leaving the other elements, closing the dropdown.
This still doesn't solve the issue of the search box opening on tab-over and then not interacting at all on click, though.
Comment #7
andy-blumAdding `tabindex="0"` to the form allows the form to "catch" the dropped focus before it falls out of whatever element has `:focus-within` enabled.
Comment #8
mherchelTrue. But clicking the button with the mouse does not. This is broken when JS is disabled in Safari. But this is a separate issue.
I don't see how that's better than the current solution.
This will also create an additional focus stop for browsers that do not have this bug.
Does the current solution not work for you??
Comment #9
andy-blumFollowing a call this morning we want to move forward with the javascript implementation first and then handle the no-js fallback in safari in a separate issue. As Mike put it "this issue with javascript disabled is not something my mom will run into", and I'm inclined to agree.
This comment deliberately does not move the issue to RTBC just yet.
Comment #10
andy-blumLooks like this still won't work as expected for two reasons:
1) A click event requires a mousedown+mouseup user interaction, but safari drops focus on mousedown. A fast click will keep the search bar open as expected, but if a user clicks slowly enough (outside the bounds of the text input) the mousedown event leads to focusout, triggering the search bar to close before the 'has-click' class is added
2) Once the 'has-click' class is added the only way for it to be removed is by using the close button. Clicking outside the search area leaves the search bar open
Comment #11
andy-blumNew patch attached that fixes the issue in Safari with javascript, and IMO improves the interface in Firefox and Chrome as well.
I added `tabindex="-1"` and that seems to allow the form wrapper to "catch" focus once it leaves the input element. The only remaining issue is the button is unusable in safari w/o javascript
Comment #12
mherchelComment #13
andy-blumPatch for 10.0.x attached
Comment #14
mherchelThis works perfectly!
Can you update the patches with code comments indicating why we're adding this attribute (with a link to the webkit bug)?
Comment #15
andy-blumComment #16
andy-blumChanged comment wording for clarity and to not upset CSpell
Comment #17
mherchelTests are passing for both 9.4.x and 10.0.x. This is good to go and a great solution. Thanks @andy-blum!
Comment #18
mherchelComment #19
andy-blumFollow up issue for the rarer safari-and-no-javascript combination #3271227: Olivero: Search toggle button doesn't work on click in Safari without JavaScript
Comment #23
lauriiiCommitted cab778d and pushed to 10.0.x. Also cherry-picked to 9.4.x. Thanks!