Tabs - add ability to intercept new tab selection
Use Case:
In one of our tabs, we have a view that manages licensing for users and business units. When adding or removing these licenses, its possible to get in a state of unsaved changes. When navigating away from that view without saving changes, a user is currently prompted before leaving and has the option to cancel and stay in place.
When using the onSelect property of the tabs, we would like to hook into the ability to stop the navigation between tabs if there are unsaved changes.
Proposed solution
Since onSelect fires before the state update in the component, we can add an additional condition to block the state update simply by returning a value from whatever function is passed in as the onSelect prop.
There is a prop named onRequestClose in Popover. I'd like to see a onRequestSelect that would allow your app to set the selected tab. That would make Tabs a controlled component and the app could decide whether to switch or not. As a controlled component a selected tab prop would override any internal state. Unfortunately, Tabs was written not as a controlled component, but more of a copy and paste==it just works with internal state--component.