-
Notifications
You must be signed in to change notification settings - Fork 1.7k
feat(tabs): add functionality of canceling a tab removal #786
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
Comments
You have the |
@inkidotcom I have a similar issue, want to veto tab selection. See #699. Perhaps my workaround there might work for you as well |
@slubowsky not quite, but thanks. from components/tabs/tabset.component.ts
so it looks like the last line is firing no matter what:
|
@adrianfaciu I guess I can create my own remove button instead of using the built-in option. I was just looking for a way to stop the removal of the tab using the existing remove handler functionality. |
@inkidotcom I am still looking for a nice solution to prevent user actions |
I'm very in need of this feature as well. A possible API in my mind can be exposing an API in Tab:
Before BS comp really removes the tab, it calls this user-defined callback first, and if it resolves to true, continue the removal; abort otherwise. |
better to create onChange on onRemove |
👍 +1 to this bug |
any update on this please? I'm facing the similar. Any help/dirty hack(workaround) is greatly appreciated |
@Hotdog1987 you can just implement your own button to close the modal depending on a modal or whatever you want. You just need to hide the P.S: your closing method should be just something like |
having the same issue too; |
I have fixed it by introducing two new input properties to the tab. the two properties are
Inside remove method, i am validating the lazyRemove, if it is true then we simply return without removing the tab. basically blocking the below line: if (tab.lazyRemove) { this.tabs.splice(index, 1); So, now we emit an event to the consuming component that remove event is triggered. On listening to this event, we can display a modal with buttons as yes or no. And on clicking of Yes, which confirms that we can remove the button, we change the canRemove boolean to true. Now, when this is set to true, we trigger the method to remove the tab with lazyRemove setting to false; |
- Add beforeRemove event to TabDirective that emits before tab removal - Allow cancellation by calling event.preventDefault() in the event handler - Update TabsetComponent.removeTab() to check for cancellation before proceeding - Maintain full backward compatibility with existing removed event - Add comprehensive unit tests for all cancellation scenarios - Add E2E tests to verify tab removal cancellation behavior Fixes #786 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
I'm trying to display an alert before a tab is removed however I'm not able to find a way to cancel the tab removal. I'm sure I'm missing something simple, but I can't find the solution.
The text was updated successfully, but these errors were encountered: