Skip to content

Conversation

@TylerJDev
Copy link
Member

Closes: https://github.com/github/primer/issues/4723

Reverts the reverted PR: #6986

Changelog

  • Ensure that the tooltip is keyboard-accessible even when the control is disabled. This is important since all SegmentedControl.IconButton will show a tooltip by default, and we want this to be accessible for keyboard users even when the control is disabled.
  • Reverts revert PR (Revert "Clean up the feature flag for primer_react_segmented_control_tooltip" #6412)
    • When we first tried to ship our cleanup of primer_react_segmented_control_tooltip, 1 integration test failed in dotcom. This is because a tooltip was now being applied on a disabled control, causing the <Tooltip> component to thrown an area. This will be resolved by the aforementioned change.

Rollout strategy

  • Patch release
  • Minor release
  • Major release; if selected, include a written rollout or migration plan
  • None; if selected, include a brief description as to why

Merge checklist

@changeset-bot
Copy link

changeset-bot bot commented Oct 21, 2025

🦋 Changeset detected

Latest commit: fe20f4f

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
@primer/react Minor
@primer/styled-react Major

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions github-actions bot added the integration-tests: recommended This change needs to be tested for breaking changes. See https://arc.net/l/quote/tdmpakpm label Oct 21, 2025
@github-actions
Copy link
Contributor

👋 Hi, this pull request contains changes to the source code that github/github depends on. If you are GitHub staff, we recommend testing these changes with github/github using the integration workflow. Thanks!

@github-actions github-actions bot temporarily deployed to storybook-preview-7047 October 21, 2025 15:48 Inactive
@github-actions github-actions bot added integration-tests: failing Changes in this PR cause breaking changes in gh/gh and removed integration-tests: recommended This change needs to be tested for breaking changes. See https://arc.net/l/quote/tdmpakpm labels Oct 21, 2025
@github-actions github-actions bot removed the integration-tests: failing Changes in this PR cause breaking changes in gh/gh label Oct 21, 2025
@github-actions github-actions bot added the integration-tests: passing Changes in this PR do NOT cause breaking changes in gh/gh label Oct 21, 2025
@primer-integration
Copy link

🟢 ci completed with status success.

@TylerJDev
Copy link
Member Author

Changes needed for release: https://github.com/github/github-ui/pull/5186/commits/3b1557f08ad7c1e6d8533bb0c80a9899d92c7021

@TylerJDev TylerJDev marked this pull request as ready for review October 21, 2025 17:03
@TylerJDev TylerJDev requested a review from a team as a code owner October 21, 2025 17:03
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR enhances the SegmentedControl component to properly handle disabled states for accessibility purposes. It removes the feature flag primer_react_segmented_control_tooltip (making tooltip behavior the default) and ensures that when aria-disabled or disabled is set on a button, click actions are prevented while maintaining keyboard-accessible tooltips.

Key changes:

  • Added support for disabled and aria-disabled props to SegmentedControl.Button and SegmentedControl.IconButton
  • Updated click handlers to check disabled state before executing actions
  • Applied appropriate styling for disabled buttons via CSS

Reviewed Changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
SegmentedControlIconButton.tsx Added disabled and aria-disabled props; removed feature flag logic
SegmentedControlIconButton.stories.tsx Added disabled and aria-disabled args to Storybook controls
SegmentedControlButton.tsx Added disabled and aria-disabled props support
SegmentedControl.tsx Modified onClick handlers to prevent actions when buttons are disabled
SegmentedControl.test.tsx Removed feature flag wrapper from tests
SegmentedControl.module.css Added styles for aria-disabled state
SegmentedControl.examples.stories.tsx Added example story demonstrating disabled buttons
SegmentedControl.dev.stories.tsx Added dev stories for testing disabled and aria-disabled states
DefaultFeatureFlags.ts Removed primer_react_segmented_control_tooltip feature flag
strong-mangos-rest.md Added changeset documenting the changes

Comment on lines +20 to +22
/** Applies `aria-disabled` to the button. This will disable certain functionality, such as `onClick` events. */
disabled?: boolean
/** Applies `aria-disabled` to the button. This will disable certain functionality, such as `onClick` events. */
Copy link

Copilot AI Oct 21, 2025

Choose a reason for hiding this comment

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

The documentation for both disabled and aria-disabled is identical. The disabled prop should be documented to clarify that it applies the aria-disabled attribute and disables click functionality, distinguishing it from the aria-disabled prop.

Suggested change
/** Applies `aria-disabled` to the button. This will disable certain functionality, such as `onClick` events. */
disabled?: boolean
/** Applies `aria-disabled` to the button. This will disable certain functionality, such as `onClick` events. */
/**
* Disables the button, preventing click functionality and applying the `aria-disabled` attribute.
* Use this prop to make the button non-interactive.
*/
disabled?: boolean
/**
* Applies the `aria-disabled` attribute to the button for accessibility purposes, but does not disable click functionality.
* Use this prop if you want the button to appear disabled to assistive technologies but remain interactive.
*/

Copilot uses AI. Check for mistakes.
onChange(index)
isUncontrolled && setSelectedIndexInternalState(index)
child.props.onClick && child.props.onClick(event)
const isDisabled = child.props.disabled === true || child.props['aria-disabled'] === true
Copy link

Copilot AI Oct 21, 2025

Choose a reason for hiding this comment

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

The disabled check is duplicated on lines 170 and 178. Consider extracting this logic into a reusable function or variable before the conditional branches to avoid repetition.

Copilot uses AI. Check for mistakes.
Comment on lines +33 to +34
disabled,
'aria-disabled': ariaDisabled,
Copy link
Member

Choose a reason for hiding this comment

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

im confused on what the difference between these two props is.
Also, does the *.docs.json need to be updated?

Copy link
Member Author

Choose a reason for hiding this comment

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

This is to be backwards compatible from what I recall. Ideally we'll remove one or the other once we reduce usage in dotcom.

Copy link
Member

Choose a reason for hiding this comment

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

should we deprecate one now then?

component: SegmentedControl,
} as Meta<typeof SegmentedControl>

export const WithDisabledButtons = () => (
Copy link
Member

Choose a reason for hiding this comment

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

does this need VRT?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah! I'll add one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

integration-tests: passing Changes in this PR do NOT cause breaking changes in gh/gh

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants