-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(Tabs): Emit the id of an activated Tab Panel #1854
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
@@ -15,10 +15,12 @@ import { useKeyboardFocus } from '../common/useKeyboardFocus' | |||
export type TabsProps = { | |||
/** The number of the active tab. Corresponds to its `tab` value. */ | |||
activeTab?: number | |||
/* Provides the id of the activated tab. */ | |||
onChange?: (tabId: number) => void |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should the callback include the event, as requested? I’m not sure how to achieve that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's not really necessary imo. The Button onClick handler returns the event, so you can access it if you need it.
@@ -15,10 +15,12 @@ import { useKeyboardFocus } from '../common/useKeyboardFocus' | |||
export type TabsProps = { | |||
/** The number of the active tab. Corresponds to its `tab` value. */ | |||
activeTab?: number | |||
/* Provides the id of the activated tab. */ | |||
onChange?: (tabId: number) => void |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's not really necessary imo. The Button onClick handler returns the event, so you can access it if you need it.
Co-authored-by: Aram <[email protected]>
Describe the pull request
Thank you for contributing to the project!
Please use this template to help us handle your PR smoothly.
What
This adds an
onChange
callback toTabs
that emits the id of a newly activated Tab Panel. Addresses #1846.Why
Applications can use this information, e.g. to store which Tab is active.
How
Added an
onChange
prop and call the provided function after updating the active Tab id.Checklist
Before submitting your pull request, please ensure you have done the following. Check each checkmark if you have done so or if it wasn't necessary:
Additional notes