-
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
Elements: Add support for text based inputs #51337
base: trunk
Are you sure you want to change the base?
Conversation
Also cc @aristath as he's been looking at form things. |
Flaky tests detected in 3ca066d. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/5257316933
|
Do we need to exclude more items? The input type |
You are right. We were discussing if it's longer to include or exclude. There is a longer list of them than I thought at the top of my head: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#input_types |
Actually on reflection I don't agree with this, I think an allow list is best, I'll update the PR. |
Updated to use this selector:
|
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 followed the testing instructions and I see the expected styles in the editor. But in the front-end, the default styles end up overriding the styles I've set in elements.textInput
.
Would it make sense to use the class selectors to target those blocks? I made a suggestion below.
'cite' => 'cite', | ||
'caption' => '.wp-element-caption, .wp-block-audio figcaption, .wp-block-embed figcaption, .wp-block-gallery figcaption, .wp-block-image figcaption, .wp-block-table figcaption, .wp-block-video figcaption', | ||
'cite' => 'cite', | ||
'textInput' => 'textarea, input:where([type=email],[type=number],[type=password],[type=search],[type=tel],[type=text],[type=tel],[type=url])', |
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.
'textInput' => 'textarea, input:where([type=email],[type=number],[type=password],[type=search],[type=tel],[type=text],[type=tel],[type=url])', | |
'textInput' => 'textarea, input:where([type=email],[type=number],[type=password],[type=search],[type=tel],[type=text],[type=tel],[type=url]), .wp-block-search__input, .wp-block-post-comments-form textarea', |
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 taking a look. I don't think this is the right way round. Elements are meant to be a low level API so their CSS should be as non-specific as possible. If blocks chose to override these elements then that is their decision. One option might also be to add a selector like wp-element-text-input
, so that blocks can decide to apply these rules to other elements if they want to.
Now that I'm thinking about this, I remember having the same discussion when we did this for the |
Hello. I studied this issue and the proposed solution.
And currently the Comments Form Block contains the following stylesheet:
Currently, the proposed solution is not overriding the current stylesheet associated to this block. The proposed solution could contain at least the following, in order to function accordingly to expected:
In WordPress 6.2, one proposal that is going to correctly satisfy all the needs of (A) Input and Textarea tags + (B) Core blocks (Login/out + Search + Comments form), including their -> hover and focus states <-, is the following:
This is going to continue to work when it comes the time of adding hover and focus states.
However I would like to note, that the list of inputs is large enough and their applications is very distinct from each other. Therefore it is subjective what inputs we need or doesn't need to consider. I do not not like, for instance, the current proposal, which opts out for some inputs in favor of others... Specially when you think of plugins. I don't know how the current proposal or " In addition to:
In this scenario, Or maybe you are going to think of more extensible (the perfect scenario...) ways of targeting inputs with Theme.json, such as:
This suggestion would better improve the situation for designers and plugins, while keeping it simple for casual users. A default fallback would happen when nothing is customized in Theme.json. And this whole specificity conflict will never exist again, as more blocks are introduced. I hope to help with my feedback. |
@meerhimmel thanks for the feedback. What if each type of input had its own element, so we'd have this:
|
@scruffian Your proposed solution may be the most solid, ...as long as all 22 input types are going to have a correspondent class. (Just a few input types are styled by default, but one person or team needs to be able to customize each input if needed in theme.json). My thoughts: If instead of all input types being considered in the implementation, only some inputs are given a corresponding class, we would incur in the scenario where, in order to target the leftovers, I am afraid each plugin developer and theme author would apply a solution with different specificity, (as it currently happens), which is a nightmare to solve when multiple stylesheets are combined. Not elegant. (2) The work being done by @aristath in the Form Block is also pointing in the direction of modularity as I understand: #44214 It is going to exist a Core Form Block which contains the most common input types available by default. I understand that plugins are going to expand the Form Block with more innerblocks equivalent to more input types as needed. So it would be awesome if all those plugins could target the same classes as Core does, as it happens with other elements... (3) I also suspect that your proposal @scruffian is going to enable the style engine the needed flexibility to output styles in simpler ways. If it happens, a deprecation of input styles may not be hard to outcome in this scenario. |
This ticket is still listed on the WordPress 6.5 editor tickets board. Though it hasn't seen any movement in a while 🤔 We are 1 week out from Beta 1. Is this still something we want to / can get in before then? Whats currently blocking this PR? |
Lack of agreement about whether this is the right approach. I suggest we take it off the 6.5 board. |
What is needed to solve this for 6.7? |
Also is there an open issue for this that should be linked to the PR? |
Some agreement about the selectors to use. Should we target all inputs, or only specific types? |
If we don't target all inputs, there will be requests for adding more. |
'cite' => 'cite', | ||
'caption' => '.wp-element-caption, .wp-block-audio figcaption, .wp-block-embed figcaption, .wp-block-gallery figcaption, .wp-block-image figcaption, .wp-block-table figcaption, .wp-block-video figcaption', | ||
'cite' => 'cite', | ||
'textInput' => 'textarea, input:where([type=email],[type=number],[type=password],[type=search],[type=tel],[type=text],[type=tel],[type=url])', |
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.
With the text area and inputs bundled together as textInput, there is no way to for example have different padding in a text area compared to a text input, right? And I think we need to be able to do that.
What?
Adds support for textarea and text-based inputs elements to theme.json.
Why?
Many themes want to control the display of textareas and other inputs, and this will allow them to do it: eg. https://github.com/WordPress/community-themes/pull/41/files
How?
Adds
textInput
to the valid elements, with a selector to targettextarea
and other text basedinput
elements. The other changes are whitespace. We'll have to followup with a PR to add this to the UI later.Testing Instructions
This can be tested in the bluenote theme, using this PR: https://github.com/WordPress/community-themes/pull/41/files. You will need to add a post comment form block to a template to see it.
Screenshots or screencast