Approach to prevent a tab change (sl-tab-group) #1970
-
If I had to pick a favourite shoelace element, However, I have a use case which I don't think I can achieve with sl-tab-group. I'm looking for a way to intercept a tab change and prevent it from occurring. If anyone has some suggestions, that'd be appreciated. Why? I hope to use this to provide a courtesy prompt to users to confirm the tab change in sensitive situations where state can be lost (be that unsaved edits, video calls, socket connections whatever..) Here's a contrived example. Imagine a tab group.
The editor tab is active and the user is filling out a complex form. Ordinarily, the user clicks a different tab and the tab changes but in this situation, the user has some uncommitted edits to the form and changing tabs would discard those. I'd like to swoop in and prompt the user whether they would like to leave (discarding changes) or stay (continue editing).
Does any one know of a way I could intercept and prevent a tab change? I see an The missing ingredient is being able to prevent a tab change. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Yippee. Achieved. Very straight forward and embarrassed I didn't consider it before posting my question. Doh.
|
Beta Was this translation helpful? Give feedback.
Yippee. Achieved. Very straight forward and embarrassed I didn't consider it before posting my question. Doh.
sl-tab
click event; and