Skip to content

Ensure focused search input in header renders consistently across breakpoints #1317

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

Merged
merged 9 commits into from
May 27, 2025

Conversation

paulrobertlloyd
Copy link
Contributor

@paulrobertlloyd paulrobertlloyd commented May 22, 2025

Fixes #1058 (comment)

  • Ensures search focus is consistent across breakpoints
  • Ensures right-hand border of search input is hidden behind button
  • Ensures focused search input appears above button
  • Adds visual regression tests for focused search input

Description

@640px:

640

@641px

641

Bit less CSS too, so you know it’s right 😉

Checklist

Copy link
Contributor

@colinrotherham colinrotherham left a comment

Choose a reason for hiding this comment

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

Looks good. Thanks for the extra tweaks

Do we need to review against .nhsuk-input for anything else?

E.g. The type scale aware nhsuk-font(19) or appearance reset

.nhsuk-input {
  -moz-appearance: none; // [1]
  -webkit-appearance: none; // [1]
  appearance: none; // [1]
  border: $nhsuk-border-width-form-element solid $nhsuk-form-border-color; // [2]
  border-radius: 0;
  box-sizing: border-box;
  min-height: 40px;
  margin-top: 0;
  padding: nhsuk-spacing(1);
  width: 100%;

  @include nhsuk-font(19);

  &:focus {
    @include nhsuk-focused-input;
  }
}

@colinrotherham
Copy link
Contributor

@paulrobertlloyd Did you look at the grey border that probably needs turning off?

Screenshot 2025-05-22 at 12 35 38

@paulrobertlloyd
Copy link
Contributor Author

@colinrotherham Have added .nhsuk-input to .nhsuk-header__search-input so can inherit common input styles. It could be argued both ways whether this is useful or not; many of the values need to be overridden (both on the blue header, but then also the white header which has a thinner border width).

@colinrotherham colinrotherham self-requested a review May 27, 2025 15:58
@@ -552,7 +552,7 @@ $_header-item-padding: 12px;
}

.nhsuk-header__navigation-container {
border-top-color: $color_nhsuk-grey-5;
border-color: $color_nhsuk-grey-4;
Copy link
Contributor

Choose a reason for hiding this comment

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

@paulrobertlloyd On the blue nav this border colour has much stronger contrast

Are you happy if we do the same for the white one—picking the darker grey?

Comment on lines +107 to +118
// Expand header account by 1px to ensure the search
// input does not appear to be taller when inline
&::before {
content: "";
display: block;
position: absolute;
top: -1px;
right: 0;
bottom: -1px;
left: 0;
border: 1px solid nhsuk-shade($color_nhsuk-blue, 20%);
border-radius: $nhsuk-border-radius + 1px;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

@paulrobertlloyd I've switched to ::before with a regular border here

Testing in older Safari showed that outline: 1px… didn't follow border-radius 😭

We also only need to offset the vertical height (making it appear taller, but not wider)

Comment on lines +171 to +173
// Adjust optical alignment due to the handle appearing
// to push the magnifying glass circle to the top left
margin: 0 -2px -2px 0;
Copy link
Contributor

Choose a reason for hiding this comment

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

Hope this is alright?

Although perfectly aligned, the magnifying glass seemed pushed into the top left

Similarly we had a 2px transparent border on the left which needed to be offset back to 12px

Adjustments

Comment on lines +189 to +190
padding-right: $_header-item-padding;
padding-left: $_header-item-padding - $nhsuk-border-width-form-element;
Copy link
Contributor

@colinrotherham colinrotherham May 27, 2025

Choose a reason for hiding this comment

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

  1. Right padding was good
    We've already used -2px margin to hide the 2px transparent border

  2. Left padding appeared 2px too wide (14px not 12px)
    For comparison see screenshot in comment above

Comment on lines +203 to +213
// Hide search input clear button (IE)
&::-ms-clear {
display: none;
}

// Hide search input icon and cancel button (WebKit, Blink)
&::-webkit-search-decoration,
&::-webkit-search-cancel-button {
appearance: none;
}

Copy link
Contributor

Choose a reason for hiding this comment

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

When text is entered we should remove the "clear" icon

Although the icon wasn't visible by default, space was still reserved for it

@colinrotherham colinrotherham self-requested a review May 27, 2025 16:17
Copy link

Copy link
Contributor

@colinrotherham colinrotherham left a comment

Choose a reason for hiding this comment

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

Looks brill 🙌

I've pushed some more changes in (unrelated to focus styles, sorry) but see what you think

Once merged, can we give this bit some thought?

  1. Log out colour on :hover stays blue
  2. Account name colour (blue, but not a link)
White account items

@paulrobertlloyd
Copy link
Contributor Author

Thanks so much for the extra polish @colinrotherham!

@paulrobertlloyd paulrobertlloyd merged commit 0e7286c into header-breaking-changes May 27, 2025
13 checks passed
@paulrobertlloyd paulrobertlloyd deleted the header-search-fixes branch May 27, 2025 16: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.

2 participants