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

Fix Sass warning for extending a compound selector #1933

Merged
merged 1 commit into from
Feb 19, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
useful summary for people upgrading their application, not a replication
of the commit log.

## Unreleased

* Fix Sass warning for extending a compound selector ([PR #1933](https://github.com/alphagov/govuk_publishing_components/pull/1933))

## 24.3.0

* Fix cookie banner preview in the component guide ([PR #1935](https://github.com/alphagov/govuk_publishing_components/pull/1935))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,21 @@ $large-input-size: 50px;
}
}

%gem-c-search-input-focus {
Copy link
Contributor

Choose a reason for hiding this comment

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

Funnily, it seems like this is what I had originally done in the PR that introduced this warning, but it was suggested to extend the original selector instead 😆
#1752 (comment)

Copy link
Member Author

Choose a reason for hiding this comment

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

@danacotoran ah ha that's good to see. It looks like it was very hard to anticipate that this would have the additional effects it did (I thought I was only removing a warning when I looked at this, I had no idea it produced 59 extra code outputs)

outline: $govuk-focus-width solid $govuk-focus-colour;
// Ensure outline appears outside of the element
outline-offset: 0;
// Double the border by adding its width again. Use `box-shadow` for this // instead of changing `border-width`
// Also, `outline` cannot be utilised here as it is already used for the yellow focus state.
box-shadow: inset 0 0 0 $govuk-border-width-form-element;

@include govuk-if-ie8 {
// IE8 doesn't support `box-shadow` so double the border with
// `border-width`.
border-width: $govuk-border-width-form-element * 2;
}
}

.gem-c-search__input[type="search"] { // overly specific to prevent some overrides from outside
@include govuk-font($size: 19, $line-height: (28 / 19));
margin: 0;
Expand All @@ -59,25 +74,14 @@ $large-input-size: 50px;
}

&:focus {
outline: $govuk-focus-width solid $govuk-focus-colour;
// Ensure outline appears outside of the element
outline-offset: 0;
// Double the border by adding its width again. Use `box-shadow` for this // instead of changing `border-width`
// Also, `outline` cannot be utilised here as it is already used for the yellow focus state.
box-shadow: inset 0 0 0 $govuk-border-width-form-element;

@include govuk-if-ie8 {
// IE8 doesn't support `box-shadow` so double the border with
// `border-width`.
border-width: $govuk-border-width-form-element * 2;
}
@extend %gem-c-search-input-focus;
}
}

@include govuk-compatibility(govuk_template) {
// ultra specific rule overrides focus styling from govuk_template
#global-header .gem-c-search__input[type="search"]:focus { // stylelint-disable selector-max-id
@extend .gem-c-search__input[type="search"]:focus; // stylelint-disable scss/at-extend-no-missing-placeholder
@extend %gem-c-search-input-focus;
}
}

Expand Down