-
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
Long slugs breaking summary panel UI #64053
Conversation
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.
To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
Size Change: +2.44 kB (+0.14%) Total Size: 1.76 MB
ℹ️ View Unchanged
|
…URL is extremely long
@jameskoster Thanks for the review. I have changed the CSS to truncate URL when they are extremely long. |
Thank you! This is working for me, let's get a review from the components team. |
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.
Thank you for the ping, @jameskoster !
We do have a Truncate
component that should this use case perfectly — the only tweak that we'd have to make for the best results is to make sure that children
of <Truncate />
are strings (and not JSX).
diff --git a/packages/editor/src/components/post-url/panel.js b/packages/editor/src/components/post-url/panel.js
index be32b40eaf..aca36566c0 100644
--- a/packages/editor/src/components/post-url/panel.js
+++ b/packages/editor/src/components/post-url/panel.js
@@ -3,7 +3,11 @@
*/
import { useMemo, useState } from '@wordpress/element';
import { useSelect } from '@wordpress/data';
-import { Dropdown, Button } from '@wordpress/components';
+import {
+ Dropdown,
+ Button,
+ __experimentalTruncate as Truncate,
+} from '@wordpress/components';
import { __, sprintf } from '@wordpress/i18n';
import { safeDecodeURIComponent } from '@wordpress/url';
import { store as coreStore } from '@wordpress/core-data';
@@ -86,7 +90,9 @@ function PostURLToggle( { isOpen, onClick } ) {
aria-label={ sprintf( __( 'Change link: %s' ), decodedSlug ) }
onClick={ onClick }
>
- { isFrontPage ? postLink : <>/{ decodedSlug }</> }
+ <Truncate numberOfLines={ 1 }>
+ { isFrontPage ? postLink : `/${ decodedSlug }` }
+ </Truncate>
</Button>
);
}
diff --git a/packages/editor/src/components/post-url/style.scss b/packages/editor/src/components/post-url/style.scss
index 45e5b2063d..104f246458 100644
--- a/packages/editor/src/components/post-url/style.scss
+++ b/packages/editor/src/components/post-url/style.scss
@@ -27,12 +27,6 @@
padding-inline-start: 0 !important;
}
-.editor-post-panel__row-control {
- .components-button.editor-post-url__panel-toggle {
- word-break: break-word;
- display: inline-block;
- text-overflow: ellipsis;
- overflow: hidden;
- white-space: nowrap;
- }
+editor-post-url__panel-toggle {
+ word-break: break-word;
}
This shouldn't require any additional style overrides.
.editor-post-url__panel-toggle { | ||
word-break: break-word; | ||
.editor-post-panel__row-control { | ||
.components-button.editor-post-url__panel-toggle { |
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.
Let's avoid using .components-*
classnames, as they are not assumed to be public APIs from the @wordpress/components
package.
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.
@ciampo Thanks for the review. Can you please review it again?
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.
Looking good, thank you! 🙏
I kindly disagree with this change. The entire purpose of this UI is ot show the full link or slug. Truncation is not a content strategy. If there's not enough space in the design to show content, the root problem is in the design in the first place. |
What?
Fixes: #64052
Why?
See this comment
Screenshots or screencast