How to control Tab Selection #6654
-
Hi, from the docs I have the prop However, I would like to control if the selection occurs at all or not. I assumed by returning a boolean this would control the change, but it seems that is not the case. My use case is that I want to have a modal warning the user that the changes to the form will be lost if he changes tab. The user can then cancel (no tab change) or proceed (tab selected should change). How would this be implemented? Thanks, |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
You can implement this with controlled. The function you pass into |
Beta Was this translation helpful? Give feedback.
You can implement this with controlled. The function you pass into
onSelectionChange
should just show the warning modal, then when "proceed" is pressed is when you actually update theselectedKey
. Here's an example: https://codesandbox.io/p/sandbox/ancient-wind-mxxvzh?file=%2Fsrc%2FApp.js