-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Search block: update alignment and icon button width #54773
Conversation
…utton styles, mainly the text:center Remove max-width change so that it doesn't affect search buttons in the header
…utton styles, mainly the text:center Remove max-width change for buttons with icons only so that it doesn't affect search button icons in the header or in narrow widths
Size Change: +193 B (0%) Total Size: 1.62 MB
ℹ️ View Unchanged
|
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.
Thanks for the PR!
Render rich text button as a button so that it inherits the default button styles, mainly the text:center
I feel that making the RichText
component itself a button
element may cause accessibility issues. This is the content obtained from ChatGPT. Also, all browsers might not apply the centered style to button elements by default.
How about leaving the button on the editor side as a div
element, like the Button block, and add text:align:center
to style.css
?
text-align: center; |
Remove max-width change for buttons with icons only so that it doesn't affect search button icons in the header or in narrow widths
This style is necessary to ensure the width of the input field in the mobile viewport and to prevent overflow, as mentioned in this comment. I'm hoping to find a style that doesn't overflow and has the desired width depending on where the Search block is placed 🤔
I did test this as well, and it was the second option 😄 Easy to reinstate. Thanks for double checking 👍🏻
Whoops. I did see that comment and had prepared this commit, but didn't push it 🤦🏻 Will do it now // Ensure minimum input field width in small viewports.
max-width: calc(100% - 100px);
&.has-icon {
max-width: 100%;
} |
Achieve centered text via text-align in editor.scss
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.
When a search box has an expandable input field and is in "button only" mode, provide a max-width for the button and take away 100px when the form is expanded to avoid text wrapping and overflow in narrow viewport widths. When the search form is collapsed revert to max-width of 100% to ensure the button fills its container. The input is not there so we don't need the 100px.
When a search box has an expandable input field and is in "button only" mode, provide a max-width for the button and take away 100px when the form is expanded to avoid text wrapping and overflow in narrow viewport widths. When the search form is collapsed revert to max-width of 100% to ensure the button fills its container. The input is not there so we don't need the 100px.
What?
text:center
Why?
-100px
in thecalc()
formula was causing the button to be a bit squishedTesting Instructions
I'm using 2023 to test, though this should work in other block themes.
Add a search block to a page. Use text for the button label and add a break point so you can see how the text is aligned.
Save the page. The search block button text alignment in the editor should match the frontend.
Add a search block to a navigation block or in the header, or elsewhere where space is constricted.
Select button with icon and button only options for the search block. Save and check the frontend: