Skip to content
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

Add styling for site search input 'flowing' into dropdown #4220

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

owenatgov
Copy link
Contributor

@owenatgov owenatgov commented Oct 15, 2024

Change

Adds a visual cue to the site search so that users whre zoomed into the input know that there is a dialog below that they may be able to interact with. When a dialog is displayed, the input will be given 'bottomless' styling to remove it's bottom border, making it visually flow into the menu and drawing the eye down.

This applies any time there's a visible drop down, so for any number of results and when the 'no results' dialog displays.

Fixes #4015

Visual changes

Scenario Before After
Input focused Focused site search without bottomless styling Focused site search with bottomless styling
Input not focused (theoretically impossible without messing with inspect) Unfocused site search without bottomless styling Unfocused site search with bottomless styling
Forced colours (used Firefox's dark theme) Site search in forced colours mode without bottomless styling Site search in forced colours mode with bottomless styling

Notes

This PR follows alphagov/accessible-autocomplete#753. See alphagov/accessible-autocomplete#753 (comment) for testing notes from that PR.

There's a little gap between the fake :before border at the top of the dropdown and the first item's top edge when highlighted. This is becuase we found through testing that some forced colour modes set the colour of the :before element to be the same ass the background colour of the dropdown, effectively erasing it. If the top item is at the very top of the dropdown, right under the input, and is highlighted, it looks like the bottom border of the input making this effect even more subtle. The gap helps with drawing the eye down.

Copy link

netlify bot commented Oct 15, 2024

You can preview this change here:

Name Link
🔨 Latest commit 65a9f5a
🔍 Latest deploy log https://app.netlify.com/sites/govuk-design-system-preview/deploys/6716670c6bc07e0008c4c032
😎 Deploy Preview https://deploy-preview-4220--govuk-design-system-preview.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@hazalarpalikli
Copy link

hazalarpalikli commented Oct 16, 2024

Thank you Owen! I noticed a minor issue that I wanted to bring to your attention. I realised I didn’t clearly indicate this in my designs: could we align the scroll with the hover state border? It creates a much cleaner and neater appearance. We are also using the same alignment in the current designs. Attaching designs below

Screenshot 2024-10-16 at 14 58 57

Uploading Screenshot 2024-10-16 at 15.02.52.png…

@selfthinker
Copy link
Contributor

I've not tested this yet but can do that tomorrow.
But from a quick glance I noticed that the search icon now jumps between not having typed anything yet and starting to type.

animated gif showing what's described above

@owenatgov owenatgov force-pushed the site-search-visual-cue-when-dropdown branch from 001dc84 to f40b221 Compare October 18, 2024 11:24
@owenatgov
Copy link
Contributor Author

Chat about this with @hazalarpalikli off-github and unfortunately I haven't been able to move the scrollbar down to line up with the first item.

It's really hard to 'move' the scrollable area of an element whilst still maintaining just one element. I've tried a few things like a white box shadow or a border to emulate white space above the menu but the tricky part is always getting the :before fake border to leave the menu because of the same menu's overflow styling which we want to maintain. That's besides the fact that using something like a border or a box shadow to mock an element being taller than it actually is creates a lot of complexity and risk.

We could resolve this by using a menu 'wrapper' element with some top padding that would contain the ul, that way the ulcould still be scrollable whilst having some non-scrollable space above it. However in order to touch the runtime markup we'd need to change the accessible autocomplete, which means coordinating a release of the autocomplete which means this will get significantly delayed. I think it'd be good to move this upstream and solve the issue eventually but I suggest not for right now. I'm open to alternative suggestions for how to resolve this but I'd rather not spend too much more time on this specific issue for the moment.

In some more positive news, I've managed to resolve @selfthinker's bug. As far as I'm concerned this is now ready for accessibility reviewwhen @selfthinker has time, then it'll be ready for code review.

@CharlotteDowns
Copy link
Contributor

I LOVE THIS!!

Means that users who are very zoomed in can see that there is something below the input to interact with
@owenatgov
Copy link
Contributor Author

Update: I spotted another visual issue. Because the separator was positioned as a block element inside the menu, it disappears when you scroll down:

menu scrolled down with separator not visible

Good news though is that in solving this, I managed to solve @hazalarpalikli's scrollbar bug after all 🎉

The separator is now a pseudo element of the wrapper psotioned at the bottom of the input, only visible via :has. The use of :has means this will be an enhancement and the separator won't be available to browsers that don't support it, however the bottomless input styling is still present.

Speaking of that, I've also added some space between the first list item and the input using a top border that I adjust via forced-colors-mode. This is a little hacky but it does work from my own quick testing using firefox's light and dark colour themes and windows high contrast mode via AssistivLabs.

I've also done some very quick browser testing in Chrome and Safari macOS and its looking good there too.

@owenatgov owenatgov force-pushed the site-search-visual-cue-when-dropdown branch from f40b221 to 65a9f5a Compare October 21, 2024 14:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Autocomplete: Lack of visual cue for results
4 participants