Only close sidebar if the event target is in body #64
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.
The svg for the left/right arrows were being swapped when the nav bar expanded. If this happened on click, the svg clicked would no longer be in the document and the nav bar would collapse immediately after expanding.
Stopping event prorogation in the click event was another way to fix this; however, that would leave the possibility of this happening again with a different sidebar nav element in the future. I think ignoring events that happened on nodes that are no longer in the document body will fix all similar cases too.
🐛 Demo
Note: You need to click a menu item in the top nav bar, like text resizer, before this behavior will emerge)
Screen.Recording.2024-12-11.at.11.36.08.AM.mov