Skip to content

feat(a11y): allow users to pass custom onclick handler to segmented controls buttons - #1447

Merged
Stefan3002 merged 1 commit into
canonical:mainfrom
Stefan3002:allow-custom-on-click-segmented-controls
Oct 16, 2026
Merged

Stefan3002 merged 1 commit into
canonical:mainfrom
Stefan3002:allow-custom-on-click-segmented-controls

Conversation

@Stefan3002

@Stefan3002 Stefan3002 commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

Done

  • Allow users to pass custom onClick event handler when clicking the button of a segmented controls.
  • This would allow users to do custom logic such as navigating to a different slug and showing the dynamic content there. (maybe they want to keep a different URL for all of the cases)

QA

Pinging @canonical/react-library-maintainers for a review.

QA steps

  • Run storybook
  • Navigate to the SegmentedControls component
  • Verify that it prints in the console a message when clicking a certain segmented control button

Percy steps

  • No visual changes expected

Fixes

Fixes: #AC-4750.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Changes recommended

Type the callback as a mouse-event handler and forward the click event.

1 open finding
What changed in this PR

Adds optional per-segment click handlers to SegmentedControl, with tests and Storybook examples.

Changes:

  • Adds optional onClick callbacks to segments.
  • Invokes callbacks when buttons are clicked.
  • Adds test coverage and usage examples.
File Summary
src/​components/​SegmentedControl/​SegmentedControl.tsx Adds segment click callback support.
src/​components/​SegmentedControl/​SegmentedControl.test.tsx Tests callback invocation and selection behavior.
src/​components/​SegmentedControl/​SegmentedControl.stories.tsx Demonstrates callback usage.

🧠 Review effort: Lite


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@Stefan3002
Stefan3002 force-pushed the allow-custom-on-click-segmented-controls branch from 17a5e56 to da8dfc0 Compare October 16, 2026 12:37
@Stefan3002
Stefan3002 requested a lite review from Copilot October 16, 2026 12:38

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟢 Approval recommended

No unresolved issues were identified that would block approval.

0 open findings

1 resolved since last review

🧠 Review effort: Lite

@bartaz-canonical bartaz-canonical left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

LGTM, good catch

@Stefan3002
Stefan3002 merged commit 4d0937a into canonical:main Oct 16, 2026
8 checks passed
@github-actions

Copy link
Copy Markdown

🎉 This PR is included in version 4.14.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants