-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Block popover: allow scrolling over #19769
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,6 +16,7 @@ import { | |
__experimentalBlockSettingsMenuFirstItem, | ||
__experimentalBlockSettingsMenuPluginsExtension, | ||
} from '@wordpress/block-editor'; | ||
import { Popover } from '@wordpress/components'; | ||
|
||
/** | ||
* Internal dependencies | ||
|
@@ -28,6 +29,7 @@ function VisualEditor() { | |
<BlockSelectionClearer className="edit-post-visual-editor editor-styles-wrapper"> | ||
<VisualEditorGlobalKeyboardShortcuts /> | ||
<MultiSelectScrollIntoView /> | ||
<Popover.Slot name="block-toolbar" /> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
<Typewriter> | ||
<WritingFlow> | ||
<ObserveTyping> | ||
|
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe this assumes the parent is relatively positioned. Should it be opt-in, won't this break popovers if it's not the case?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's a check for
offsetParent
. That should be enough?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/offsetParent
Interesting that
offsetParent
does seem to return the body element in Firefox. I'll adjust the check.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can check additionally if the position is absolute.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does the logic here depend that the developer apply a style to their popover to position it absolutely? Is that what you're saying by checking if the position is absolute? Otherwise, it doesn't seem very self-contained, or clear why this logic would exist here if it's something only relevant for custom popover behavior. Can we apply
position: absolute
within this component when it's appropriate? Is there any opportunity to be be smart about detecting that the popover is being rendered in a scrollable container?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm okay on the point of introducing more formal support later. It's not entirely clear to me if I would expect some impact of these changes on existing usage which doesn't use the absolute-positioned approach. You mentioned earlier "There's a check for
offsetParent
", but I don't understand specifically how that's meant to help.In any case, it seems from some brief testing that things work well enough.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess it assumes that elsewhere, the Slot is rendered such that there wouldn't be an
offsetParent
? Technically we also support an "in-place rendering" option, when there is no Slot context available. I don't think we use it anywhere ourselves. But it seems it could be impacted by these changes.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In all other cases, the popover has fixed positioning, even when rendered in place, which means that it is offset relative to the viewport and that it doesn't have an offset parent. When the popover has absolute positioning, the offset parent is the first ancestor that has a relative position.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Gotcha. I think I misunderstood how
offsetParent
was being used here. I see now it's used as an indicator of the component itself being fixed, so only if someone went out of their way to manually override the fixed property would it ever have an impact 👍There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess the comment could be clearer. 😄