diff --git a/.changeset/perf-segmentedcontrol-has-selector.md b/.changeset/perf-segmentedcontrol-has-selector.md new file mode 100644 index 00000000000..82036c5a6f1 --- /dev/null +++ b/.changeset/perf-segmentedcontrol-has-selector.md @@ -0,0 +1,5 @@ +--- +'@primer/react': patch +--- + +perf(SegmentedControl): Scope :has(:focus-visible) to direct child for O(1) lookup diff --git a/packages/react/src/SegmentedControl/SegmentedControl.module.css b/packages/react/src/SegmentedControl/SegmentedControl.module.css index 22b80ae8f33..0d936ae4637 100644 --- a/packages/react/src/SegmentedControl/SegmentedControl.module.css +++ b/packages/react/src/SegmentedControl/SegmentedControl.module.css @@ -187,7 +187,8 @@ } } - &:focus-within:has(:focus-visible) { + /* PERFORMANCE: Button is direct child of Item, scope with > for O(1) lookup */ + &:focus-within:has(> :focus-visible) { background-color: transparent; }