This repository was archived by the owner on Mar 3, 2023. It is now read-only.
Add prevent option to ::onWillDestroyPaneItem #22943
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Issue or RFC Endorsed by Atom's Maintainers
#13812
Description of the Change
This PR implements the feature requested in issue #12376. It adds a method to the parameter of the
::onWillDestroyPaneItem
callback namedprevent
which allows packages to prevent a tab from closing by adding an event listener via::onWillDestroyPaneItem
.Alternate Designs
An alternative for the requested feature overall isn't really present, as the previous implementation would close the tab no matter what or request the user to safe in case of unsaved changes. Both of these are unwanted behaviour as described in #12376.
As for alternative ways to implement the functionality, I considered
prevent
to be a (boolean) value instead of a function. However, this seemed not such a good choice mainly because I find it more intuitive to use as a function, but also because JavaScript can't enforce the value to be a boolean.Possible Drawbacks
When used incorrectly this functionality could make closing tabs impossible for users. However, simply disabling the package that uses this functionality incorrectly will solve the problem.
Verification Process
I tested the functionality by using it in the pinned-tabs-for-atom package when I created #13812. I have not yet been able to retest it yet.
Release Notes
Not applicable