Repository navigation
Block side menu show/hide detection fix - #99
Closed
matthewlipski wants to merge 3 commits into
Closed
matthewlipski wants to merge 3 commits into
matthewlipski wants to merge 3 commits into
Conversation
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This PR changes when the block side menu is shown and hidden. Previously, it only hid the block side menu when the mouse cursor was beyond the horizontal range of the editor. Now, it also hides the menu if the mouse cursor is beyond the horizontal range of the editor (includes a 100px margin to the left of the editor to account for the menu itself, so that it can be clicked). However, this approach is flawed as the menu size and position can change if a custom element is used, is which case the menu will disappear even when hovered/clicked.
There are a few alternative solutions:
The editor's vertical and horizontal range is still used to determine when the menu is shown & hidden, but does not include the left margin for the menu itself. Instead, a timer is used to keep the menu open for some time until it's hovered over, similarly to the hyperlink hover menu. With this approach, the menu won't show up until the block it's next to is hovered.
The editor's vertical and horizontal range is still used to determine when the menu is shown, but again does not include a margin for the menu itself. To hide the menu, we check if the mouse cursor is within the bounding box of the editor or the menu itself. This doesn't work if there is a gap between the menu and the editor, and the menu also won't show up until the block it's next to is hovered.
The editor's vertical range only is still used to determine when the menu is shown & hidden, as before. However, a parent HTML element or CSS selector pointing to a single element, is also used. While the cursor is outside this element, the menu is prevented from showing. This can be implemented in a number of ways:
DraggableBlocksextension, which defaults todocument.bodyto copy the current behaviour.DraggableBlocksextension, which defaults to e.g.#block-side-menu-detection. The user attaches this CSS ID to any HTML element, so that the menu stays hidden while the mouse cursor is outside of it. If no block with the ID is found, the behaviour is the same as the current implementation.The fix used in this PR is simpler than the alternatives and seems closest to what Notion is doing. However, I think 3.ii. is the most elegant and provides the best functionality, though I want to make sure this implementation will work for Fermat.