WordPress / gutenberg

The Block Editor project for WordPress and beyond. Plugin is available from the official repository.
https://wordpress.org/gutenberg/
Other
10.5k stars 4.2k forks source link

Popover component overlapping toolbar #64342

Open Rishit30G opened 3 months ago

Rishit30G commented 3 months ago

Description

When we try to insert a block using / (backslash) and start typing, the popover component is below the text as the results are more but as soon as the results become less the popover component moves up and overlaps the toolbar component which does not look good on the UI

My suggestion would be to keep remove the toolbar option when the popover component is active, so that we don't encounter this problem Would like others to chime in and share their opinion on this 🙇

Step-by-step reproduction instructions

Screenshots, screen recording, code snippet

https://github.com/user-attachments/assets/73d5a90f-f0ea-49d3-9d48-030b69d486f5

Environment info

Please confirm that you have searched existing issues in the repo.

Please confirm that you have tested with all plugins deactivated except Gutenberg.

stokesman commented 2 months ago

I wonder if this has been discussed before. I’d suppose it’s mostly overlooked because the expectation that one completes the use of the menu before moving the pointer.

I think for starters the placement of the popover isn’t right. It is specified as "top-start", i.e. to be placed above the rich text area if space permits. In the scenario demonstrated, that’s what causes the flip upward once the results are few enough that the popover fits above. If instead, it is specified as "bottom-start" to be placed below, the menu will stay in place. It seems better to me despite that it would allow the inverse to happen—a tall menu without enough space below will start above and then flip below with fewer options. Here‘s the suggestion in a diff:

diff --git a/packages/components/src/autocomplete/autocompleter-ui.tsx b/packages/components/src/autocomplete/autocompleter-ui.tsx
index c6c1b94deb..d9ad76774b 100644
--- a/packages/components/src/autocomplete/autocompleter-ui.tsx
+++ b/packages/components/src/autocomplete/autocompleter-ui.tsx
@@ -179,7 +179,7 @@ export function getAutoCompleterUI( autocompleter: WPCompleter ) {
                <Popover
                    focusOnMount={ false }
                    onClose={ onReset }
-                   placement="top-start"
+                   placement="bottom-start"
                    className="components-autocomplete__popover"
                    anchor={ popoverAnchor }
                    ref={ popoverRefs }