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

Merged
merged 1 commit into from
Oct 28, 2024

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 ee7ec34
🔍 Latest deploy log https://app.netlify.com/sites/govuk-design-system-preview/deploys/671fbc20118328000830af18
😎 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.

@owenatgov owenatgov force-pushed the site-search-visual-cue-when-dropdown branch 4 times, most recently from 67d59bd to 001dc84 Compare October 16, 2024 11:53
@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!!

@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
@selfthinker
Copy link
Contributor

I've tested this yesterday in Windows High Contrast Mode and Edge (three different colour schemes), Firefox browser settings (light and dark colour schemes) and the Chrome extension 'High Contrast'.
I have uploaded screenshots of everything to this folder (which can only be viewed internally).

Generally, the colours look much better than when I tested the same change in the autocomplete component. Because the previous version didn't actually use the colours the user chose, and this version does. Although, that is not a result of this change, that was already the case before, but I thought it's worth highlighting anyway because we weren't happy with the colours on the other version.

The good news is that everything looks fine.
The bad news is that the difference between having a dropdown and not having a dropdown is not as distinct in all of those tools I've tested, with the exception of the 'High Contrast' extension.

But I don't think that is generally fixable when using this kind of subtle design.
So, I'm happy for this to get merged the way it is.

Copy link
Contributor

@selfthinker selfthinker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Regarding the code, I wonder if it's worth leaving comments for some of the magic numbers? My head is not in the website code, so feel free to decide either way.

@owenatgov
Copy link
Contributor Author

I'm gonna mark this for code review off of @selfthinker's comment. After that this can finally be merged ✨

@owenatgov owenatgov marked this pull request as ready for review October 23, 2024 16:20
@owenatgov owenatgov requested a review from a team October 23, 2024 16:21
Comment on lines +60 to +63
// This is here on the wrapper element and absolute positioned under the input
// rather than on the menu because we can't move a pseudo element out of the
// menu eg: using minus margins or absolute positioning without breaking the
// menu's overflow conditions.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As a thought on this, was placing the pseudo-element on the menu and increasing the menu's negative top margin to 'move it out' something that was tried? Seems like it'd be a bit neater, though obviously, I don't know if that'd work here.

Copy link
Contributor Author

@owenatgov owenatgov Oct 25, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I gave this a go locally to quickly try to remind myself and unforunately it doesn't work. The issue is that the menu's overflow conditions mean that any negitive margin artificial positioning causes the element to disappear because it's inside a parent, the menu, with overflow-x: hidden. This doesn't seem like it would cause problems since we're talking about content in the 'y' direction, but I think this is what's noted on the overflow-y MDN page:

If overflow-x is hidden, scroll, or auto and the overflow-y property is visible (default), the value will be implicitly computed as auto.

I tried messing with the overflow so that it would only manage overflow for the bottom of the element and not the top bt couldn't figure it out. I'm open to ideas.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ack, that's rather annoying. Something that visually looks to be part of the dropdown whilst actually being detached from it feels... brittle. Probably hasn't helped with readability of stuff either.

I don't have a better idea to offer though, so I'll give it a poke assuming this is the best route available to us.

Copy link
Member

@romaricpascal romaricpascal Oct 25, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could position: fixed be helpful to keep the separator within the <ul> and at its top? There are a couple of properties you can set on a parent element that make an object using position: fixed not be fixed relative to the page, but a closer containing block.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I gave @romaricpascal's position: fixed idea a go and unfortuantely the overflow problem comes back. fixed with contain: layout as an example doesn't let the pseudo element escale the menu parent, so long as those overflow settings are in place. Same results for the other suggestions provided by MDN. I could resolve this by changing the scope to app-site-search__wrapper but that's basically what I'm doing now.

Unless there's a way to adjust the overflow settings without breaking the component I'm not sure there's a less weird solution. The actual answer IMO is to put a container around the ul which we can do upstream at a later date.

@owenatgov owenatgov force-pushed the site-search-visual-cue-when-dropdown branch from 65a9f5a to 0b19c2a Compare October 25, 2024 10:09
Copy link
Member

@querkmachine querkmachine left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few comments 'n' thoughts but nothing showstopping. 🤘

src/stylesheets/components/_site-search.scss Outdated Show resolved Hide resolved
src/stylesheets/components/_site-search.scss Outdated Show resolved Hide resolved
src/stylesheets/components/_site-search.scss Outdated Show resolved Hide resolved
src/stylesheets/components/_site-search.scss Outdated Show resolved Hide resolved
// provide some space between the list items highlight-able top edge and the
// bottom of the input.
border-top: govuk-colour("white") solid govuk-spacing(1);
box-shadow: rgba(govuk-colour("black"), 0.256863) 0 govuk-spacing(1) govuk-spacing(1); // stylelint-disable-line number-max-precision
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

May want to interpolate function too.

Suggested change
box-shadow: rgba(govuk-colour("black"), 0.256863) 0 govuk-spacing(1) govuk-spacing(1); // stylelint-disable-line number-max-precision
box-shadow: rgba(#{govuk-colour("black")}, 0.256863) 0 govuk-spacing(1) govuk-spacing(1); // stylelint-disable-line number-max-precision

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So doing this one gives me an error:

sass.Exception [Error]: $color: #0b0c0c is not a color.

I don't understand why. #0b0c0c is a colour so 🤷🏻 I wonder if this is some weird string thing.

Means that users who are very zoomed in can see that there is something below the input to interact with
@owenatgov owenatgov force-pushed the site-search-visual-cue-when-dropdown branch from 0b19c2a to ee7ec34 Compare October 28, 2024 16:30
@owenatgov owenatgov merged commit ebc7666 into main Oct 28, 2024
15 checks passed
@owenatgov owenatgov deleted the site-search-visual-cue-when-dropdown branch October 28, 2024 16:33
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
6 participants