-
Notifications
You must be signed in to change notification settings - Fork 385
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
Preview AMP tooltip displays incorrectly in editor #4590
Comments
Hi @ernee! Yeah, this is definitely an issue. In my local, the tooltip is cut off below: I'll work on this. |
If it's alright, I'll come back to this tomorrow. There doesn't look to be a quick fix, though I'm not good at CSS. For example, simply changing the |
It appears the |
Yeah, there might not be a way to keep the tooltip. |
I'd look into how the Setting button has integrated the tooltip in Gutenberg. |
1. Tooltip might not be feasibleHi @westonruter, I couldn't find a way to prevent the But this button is rendered into a single element in the DOM, and that element isn't aware of the block editor's React components. It's rendered like this because there wasn't a Slot/Fill or filter to render it properly. So the tooltip renders inside the Button, and looks bad. For example, with the 'Preview AMP' button, the tooltip is inside the button: But for the 'More tools & options' button, which looks good, the tooltip is pretty far away from the button in the DOM: |
2. SuggestionWhat do you think about simply removing the diff --git a/assets/src/block-editor/components/amp-preview.js b/assets/src/block-editor/components/amp-preview.js
index dfbace46e..ed8a4fa1e 100644
--- a/assets/src/block-editor/components/amp-preview.js
+++ b/assets/src/block-editor/components/amp-preview.js
@@ -236,25 +236,22 @@ class AMPPreview extends Component {
return (
isEnabled && ! errorMessages.length && ! isStandardMode && (
- <Tooltip text={ __( 'Preview AMP', 'amp' ) } >
- <Button
- className="amp-editor-post-preview"
- href={ href }
- label={ __( 'Preview AMP', 'amp' ) }
- isSecondary
- disabled={ ! isSaveable }
- onClick={ this.openPreviewWindow }
- ref={ this.buttonRef }
- >
- { ampFilledIcon( { viewBox: '0 0 62 62', width: 18, height: 18 } ) }
- <span className="screen-reader-text">
- {
-
/* translators: accessibility text */
-
__( '(opens in a new tab)', 'amp' )
- }
- </span>
- </Button>
- </Tooltip>
+ <Button
+ className="amp-editor-post-preview"
+ href={ href }
+ isSecondary
+ disabled={ ! isSaveable }
+ onClick={ this.openPreviewWindow }
+ ref={ this.buttonRef }
+ >
+ { ampFilledIcon( { viewBox: '0 0 62 62', width: 18, height: 18 } ) }
+ <span className="screen-reader-text">
+ {
+ /* translators: accessibility text */
+ __( '(opens in a new tab)', 'amp' )
+ }
+ </span>
+ </Button>
)
);
} That's probably not great for usability. But there's screen reader text inside the Button. And the documentation for Button says:
...and this does have an icon. |
There's a difference between the Settings button and the AMP Preview button in terms of the React components. With React Dev Tools this is what the Settings tooltip looks like when it is open: Compare with the AMP Preview button: We're missing a Nevertheless, the “Settings“ button doesn't show a <Button
icon={ cog }
label={ __( 'Settings' ) }
onClick={ toggleGeneralSidebar }
isPressed={ isEditorSidebarOpened }
aria-expanded={ isEditorSidebarOpened }
shortcut={ shortcut }
/> I'm not sure how the tooltip is being wired up for the Settings element, but it's being done differently than the AMP Preview button. I suspect that changing the tooltip to be added in the same way will fix the issue with the positioning. |
Hi Weston, The 'Settings' button has a Then, the |
Here's something pretty similar to the Settings button, and the tooltip is still covered. diff --git a/assets/src/block-editor/components/amp-preview.js b/assets/src/block-editor/components/amp-preview.js
index dfbace46e..3b28af0e0 100644
--- a/assets/src/block-editor/components/amp-preview.js
+++ b/assets/src/block-editor/components/amp-preview.js
@@ -236,25 +236,17 @@ class AMPPreview extends Component {
return (
isEnabled && ! errorMessages.length && ! isStandardMode && (
- <Tooltip text={ __( 'Preview AMP', 'amp' ) } >
- <Button
- className="amp-editor-post-preview"
- href={ href }
- label={ __( 'Preview AMP', 'amp' ) }
- isSecondary
- disabled={ ! isSaveable }
- onClick={ this.openPreviewWindow }
- ref={ this.buttonRef }
- >
- { ampFilledIcon( { viewBox: '0 0 62 62', width: 18, height: 18 } ) }
- <span className="screen-reader-text">
- {
-
/* translators: accessibility text */
-
__( '(opens in a new tab)', 'amp' )
- }
- </span>
- </Button>
- </Tooltip>
+ <Button
+ icon={ ampFilledIcon( { viewBox: '0 0 62 62', width: 18, height: 18 } ) }
+ label={ __( 'Preview AMP', 'amp' ) }
+ className="amp-editor-post-preview"
+ href={ href }
+ label={ __( 'Preview AMP', 'amp' ) }
+ isSecondary
+ disabled={ ! isSaveable }
+ onClick={ this.openPreviewWindow }
+ ref={ this.buttonRef }
+ />
)
);
} |
OK, how about just using a classic |
Good idea, that works locally. |
@amedina this is expected. The button is required to be disconnected in current versions of Gutenberg because the Preview dropdown component is not extendable. |
I see. It looks weird disconnected because the semantics of the Let's ship it and we will revise during UX review. |
Bug Description
In the editor, the tooltip to Preview AMP displays incorrectly (hidden behind another element).
Expected Behaviour
The tooltip should be fully visible.
Steps to reproduce
Screenshots
WordPress Core
Gutenberg plugin
Additional context
Do not alter or remove anything below. The following sections will be managed by moderators only.
Acceptance criteria
Implementation brief
QA testing instructions
Demo
Changelog entry
The text was updated successfully, but these errors were encountered: