Feat: add new preventTextSelectionOverflow
prop
#1170
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.
closes #1168
Currently, when initiating text selection from within a floating element and dragging the pointer outside, the text outside the floating element gets selected.
This PR introduces a new prop
preventTextSelectionOverflow
that controls whether text-selection overflow is allowed. By defaultpreventTextSelectionOverflow
will betrue
.The affected builders are:
Link preview already implemented preventing text-selection overflow, so now the link preview builder gets this behavior from
usePopper
like the other builders mentioned above.Tooltip, however, is not added in this PR because the tooltip closes when the pointer leaves the grace zone. The link preview has logic to prevent closing when text selection occurred. In a later PR, I will merge a lot of the behaviors of the tooltip and link preview, at which point tooltip will inherit the prevention of text-selection overflow and not close itself after the pointer leaves after text selection.
Also, the dialog is not added in this PR because the overlay already takes care of not allowing user selection because the overlay spans the entire viewport.
I haven't added tests yet because I am not sure how you would test this behavior without bending backwards
Here are videos showing all the affected builders before and after.
Context menu
context.menu.mov
Dropdown menu
dropdown.menu.mov
Link preview - same behavior as before
link.preview.mov
Combobox
combobox.mov
Select
select.mov
Menubar
menubar.mov
Popover
popover.mov