Conversation
…e=search]/[role=group] corners Corner radius on [role="search"] and [role="group"] children was determined via :first-child/:last-child, which counts hidden elements too. A hidden input placed before/after the visible children flattened the rounded end of the group. Now the leftmost/rightmost visible child is determined by ignoring [hidden] and [type="hidden"] siblings, using a general sibling selector for the left side (all browsers) and :has() for the right side (with a :not(:last-child) fallback for browsers without :has() support). Fixes picocss#736
3 tasks done
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #736.
[role="search"]and[role="group"]decide which child gets the rounded corner via:first-child/:last-child. Those pseudo-classes count[hidden]/[type="hidden"]elements too, so a hidden field placed before/after the visible children flattens the rounded end of the group (as shown in the issue's JSFiddle repro).This PR makes the left/right corner logic ignore
[hidden]and[type="hidden"]elements when determining the visual first/last child::not([hidden], [type="hidden"]) ~ :not([hidden], [type="hidden"])), which works in all browsers.:has()to detect a following visible sibling, gated behind@supports selector(:has(*)), with the original:not(:last-child)behavior kept as a fallback for browsers without:has()support.Screenshots
Before fix — hidden input flattens the left corner of the search form:
After fix — rounded corners are preserved regardless of hidden input position:
Tested with:
hiddeninput as first child,hiddenattribute (non-type=hidden) as first child, andhiddeninput as last child — all render with correctly rounded corners, matching a normal search form with no hidden input.Test plan
yarn lint/yarn build:csspassyarn build(full pipeline: lint, compile, themes, autoprefix, minify) completes; all/cssoutput regenerated and committed per CONTRIBUTING.mdhiddenattribute vstype="hidden")