Skip to content

fix(SegmentedRadioGroup): ignore non-option siblings#2685

Open
Su9DenLY wants to merge 2 commits into
mainfrom
fix/segmented-radio-group/popover-border
Open

fix(SegmentedRadioGroup): ignore non-option siblings#2685
Su9DenLY wants to merge 2 commits into
mainfrom
fix/segmented-radio-group/popover-border

Conversation

@Su9DenLY

@Su9DenLY Su9DenLY commented May 21, 2026

Copy link
Copy Markdown

Summary by Sourcery

Adjust segmented radio group styling to only treat actual option elements as segmented siblings, preventing layout artifacts when other elements are present.

Bug Fixes:

  • Ensure segmented radio group borders and corner radii are computed only among option elements, ignoring non-option siblings.
  • Prevent checked-state background styling from leaking across non-option siblings within the segmented radio group.

@Su9DenLY
Su9DenLY requested a review from zamkovskaya as a code owner May 21, 2026 07:26
@sourcery-ai

sourcery-ai Bot commented May 21, 2026

Copy link
Copy Markdown
Contributor
Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Adjusts SegmentedRadioGroup option styling selectors so that visual grouping and borders apply only to actual option siblings, correctly ignoring any non-option siblings, and refines the checked-state overlap behavior.

File-Level Changes

Change Details Files
Limit border and radius styling logic to actual option siblings instead of relying on generic first/last-child and adjacent-sibling selectors.
  • Replaced generic :first-child/:last-child-based rules with selectors that detect presence or absence of other .segmented-radio-group__option siblings using ~ combinators and :has to determine edge options for border radii.
  • Updated border-inline-start and border-inline-end width logic to only remove borders when the element follows or precedes another option, avoiding interference from non-option siblings.
  • Ensured start and end border radii are applied only when there are no prior or subsequent option siblings, making the layout robust when extra elements are present between options.
src/components/SegmentedRadioGroup/SegmentedRadioGroup.scss
Refine checked option background overlap behavior when multiple options are present, using sibling and :has-based selectors.
  • Added a &_checked ~ & rule so that non-checked options following a checked option can clear their before pseudo-element background when not between additional options.
  • Used a more specific combination of &_checked and ~ .segmented-radio-group__option ~ .segmented-radio-group__option to avoid unwanted background artifacts when multiple options and non-option siblings are mixed.
src/components/SegmentedRadioGroup/SegmentedRadioGroup.scss

Possibly linked issues

  • #0: PR adjusts SegmentedRadioGroup CSS to ignore non-option siblings, fixing border breakage when options are wrapped in Popover.

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Hey - I've found 1 issue, and left some high level feedback:

  • The new selectors using :has and sibling combinators are quite dense; consider adding comments or simplifying them (e.g., extracting shared selector pieces into variables/mixins) to make the intent and grouping behavior easier to understand and maintain.
  • Since :has is still not universally supported in all environments, verify that this component’s supported browser matrix is aligned with :has usage or provide a graceful fallback for environments without :has.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The new selectors using :has and sibling combinators are quite dense; consider adding comments or simplifying them (e.g., extracting shared selector pieces into variables/mixins) to make the intent and grouping behavior easier to understand and maintain.
- Since :has is still not universally supported in all environments, verify that this component’s supported browser matrix is aligned with :has usage or provide a graceful fallback for environments without :has.

## Individual Comments

### Comment 1
<location path="src/components/SegmentedRadioGroup/SegmentedRadioGroup.scss" line_range="147-150" />
<code_context>
             }
         }

+        &_checked ~ & {
+            &:not(&_checked ~ #{$block}__option ~ #{$block}__option)::before {
+                background-color: transparent;
+            }
</code_context>
<issue_to_address>
**suggestion (bug_risk):** Complex nested selector with & inside :not() is brittle and risks subtle bugs when multiple options are checked or markup changes.

This selector chain is difficult to reason about, particularly the `&` inside `:not()`, which makes it hard to confirm it only affects options after the checked one and behaves correctly when multiple `_checked` options can briefly coexist. Please simplify this by splitting it into clearer selectors or using explicit state/modifier classes to express the relationship between checked and non-checked options, even if it requires a bit more markup or JS.

```suggestion
        // For all options that come after a checked option, reset the background
        &_checked {
            & ~ & {
                &::before {
                    background-color: transparent;
                }
            }
```
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment thread src/components/SegmentedRadioGroup/SegmentedRadioGroup.scss Outdated
@gravity-ui

gravity-ui Bot commented May 21, 2026

Copy link
Copy Markdown
Contributor

Preview is ready.

@gravity-ui

gravity-ui Bot commented May 21, 2026

Copy link
Copy Markdown
Contributor

🎭 Component Tests Report is ready.

@Su9DenLY Su9DenLY linked an issue May 21, 2026 that may be closed by this pull request
2 tasks
@zamkovskaya
zamkovskaya requested review from ValeraS and amje May 25, 2026 09:23
@amje

amje commented May 26, 2026

Copy link
Copy Markdown
Contributor

@Su9DenLY Let's hold with this fix, maybe it's not needed at all. Waiting for the user's answer

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.

Can't use Popover with SegmentedRadioGroup

2 participants