Skip to content
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

feat: Editorial review: Add content to cover the field-sizing property #32489

Merged
merged 42 commits into from
Apr 15, 2024

Conversation

chrisdavidmills
Copy link
Contributor

Description

Chrome 123 supports the field-sizing property, which is used to size textual form elements and textareas by their content, rather than sticking to a fixed size. This PR adds data for the new property.

Motivation

Additional details

Related issues and pull requests

@chrisdavidmills chrisdavidmills requested a review from a team as a code owner February 29, 2024 17:54
@chrisdavidmills chrisdavidmills requested review from estelle and removed request for a team February 29, 2024 17:54
@chrisdavidmills chrisdavidmills marked this pull request as draft February 29, 2024 17:55
@github-actions github-actions bot added Content:CSS Cascading Style Sheets docs size/m [PR only] 51-500 LoC changed labels Feb 29, 2024
Copy link
Contributor

github-actions bot commented Feb 29, 2024

Preview URLs

(comment last updated: 2024-04-15 21:02:52)

@github-actions github-actions bot added the Content:HTML Hypertext Markup Language docs label Mar 1, 2024
@chrisdavidmills chrisdavidmills marked this pull request as ready for review March 1, 2024 14:09
@chrisdavidmills chrisdavidmills requested a review from a team as a code owner March 1, 2024 14:09
@chrisdavidmills chrisdavidmills changed the title Add content to cover the field-sizing property Tech review: Add content to cover the field-sizing property Mar 1, 2024
files/en-us/web/css/field-sizing/index.md Outdated Show resolved Hide resolved
files/en-us/web/css/field-sizing/index.md Outdated Show resolved Hide resolved
files/en-us/web/css/field-sizing/index.md Outdated Show resolved Hide resolved
files/en-us/web/html/element/input/index.md Show resolved Hide resolved
@chrisdavidmills
Copy link
Contributor Author

Thanks for the helpful review comments, @tkent-google! I have responded to all of them. Please let me know if you think anything else is needed here.

Copy link

@tkent-google tkent-google left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@chrisdavidmills chrisdavidmills changed the title Tech review: Add content to cover the field-sizing property feat: Editorial review: Add content to cover the field-sizing property Mar 5, 2024
@estelle estelle requested a review from dipikabh April 10, 2024 01:47
Copy link
Contributor

@dipikabh dipikabh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fun feature, thanks for documenting it, @chrisdavidmills 👍

I've added edit suggestions for you to consider.

files/en-us/web/css/field-sizing/index.md Outdated Show resolved Hide resolved
files/en-us/web/css/field-sizing/index.md Outdated Show resolved Hide resolved
files/en-us/web/css/field-sizing/index.md Outdated Show resolved Hide resolved
files/en-us/web/css/field-sizing/index.md Outdated Show resolved Hide resolved
files/en-us/web/css/field-sizing/index.md Outdated Show resolved Hide resolved
files/en-us/web/css/field-sizing/index.md Outdated Show resolved Hide resolved
files/en-us/web/css/field-sizing/index.md Outdated Show resolved Hide resolved
files/en-us/web/css/field-sizing/index.md Outdated Show resolved Hide resolved
files/en-us/web/html/element/input/index.md Show resolved Hide resolved
files/en-us/web/html/element/select/index.md Outdated Show resolved Hide resolved
chrisdavidmills and others added 5 commits April 12, 2024 11:16
Co-authored-by: Dipika Bhattacharya <dipika@foss-community.org>
Co-authored-by: Dipika Bhattacharya <dipika@foss-community.org>
Co-authored-by: Dipika Bhattacharya <dipika@foss-community.org>
Co-authored-by: Dipika Bhattacharya <dipika@foss-community.org>
Co-authored-by: Dipika Bhattacharya <dipika@foss-community.org>
chrisdavidmills and others added 9 commits April 12, 2024 11:34
Co-authored-by: Dipika Bhattacharya <dipika@foss-community.org>
Co-authored-by: Dipika Bhattacharya <dipika@foss-community.org>
Co-authored-by: Dipika Bhattacharya <dipika@foss-community.org>
Co-authored-by: Dipika Bhattacharya <dipika@foss-community.org>
Co-authored-by: Dipika Bhattacharya <dipika@foss-community.org>
Co-authored-by: Dipika Bhattacharya <dipika@foss-community.org>
Co-authored-by: Dipika Bhattacharya <dipika@foss-community.org>
Co-authored-by: Dipika Bhattacharya <dipika@foss-community.org>
Co-authored-by: Dipika Bhattacharya <dipika@foss-community.org>
chrisdavidmills and others added 3 commits April 12, 2024 12:11
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Dipika Bhattacharya <dipika@foss-community.org>
Co-authored-by: Dipika Bhattacharya <dipika@foss-community.org>
chrisdavidmills and others added 3 commits April 12, 2024 12:14
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Copy link
Contributor

@dipikabh dipikabh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The updates are looking good, thanks @chrisdavidmills.

Just two comments with a few nits, but leaving a +1. Feel free to merge when you're ready with the changes.

files/en-us/web/html/element/input/index.md Outdated Show resolved Hide resolved
files/en-us/web/css/field-sizing/index.md Outdated Show resolved Hide resolved
Copy link
Member

@estelle estelle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good write up. Made a few comments.

files/en-us/web/css/field-sizing/index.md Outdated Show resolved Hide resolved
- `content`
- : Allows the element to adjust its size to fit its contents.
- `fixed`
- : Sets a fixed size for the element.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should note that this is the browser default for elements with default preferred size.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call, however, I've just added "This is the default value." If you look at the computed values on any element, a default field-sizing: fixed will be shown.

Specifically, this property affects the following elements:

- Form input types that accept direct text input from users. This includes [`email`](/en-US/docs/Web/HTML/Element/input/email), [`number`](/en-US/docs/Web/HTML/Element/input/number), [`password`](/en-US/docs/Web/HTML/Element/input/password), [`search`](/en-US/docs/Web/HTML/Element/input/search), [`tel`](/en-US/docs/Web/HTML/Element/input/tel), [`text`](/en-US/docs/Web/HTML/Element/input/text), and [`url`](/en-US/docs/Web/HTML/Element/input/url) types.
- If no minimum width is set on the control, it will only be as wide as the text cursor.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

need to clarify that this is if content is set. Not true if fixed is set, where the size is set by the size attribute or the browser's default preferred size. If we change the h3 heading to "Elements affected by field-sizing: content and intro statement this edit is not needed, and the multiple "elements with field-sizing: content set" can be removed from bullets below.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've made the heading change, however, I think most of those instances are still needed — the sentences read a bit strangely when removed, and some of them are important so that the sentence makes sense.

files/en-us/web/css/field-sizing/index.md Outdated Show resolved Hide resolved
files/en-us/web/css/field-sizing/index.md Outdated Show resolved Hide resolved

The sizing flexibility provided to form controls by `field-sizing: content` can be overridden if you use other CSS sizing properties. Avoid setting a fixed {{cssxref("width")}} and {{cssxref("height")}} when using `field-sizing: content` because they will reimpose a fixed size on the control. However, using properties like {{cssxref("min-width")}} and {{cssxref("max-width")}} alongside `field-sizing: content` is quite effective because they allow the control to grow and shrink with the entered text and also prevent the control from becoming too large or too small.

It is also useful to combine `field-sizing: content` with form attributes like [`maxlength`](/en-US/docs/Web/HTML/Element/input#maxlength), which will cause the control to stop growing in size when the maximum character limit is reached.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In most cases, setting maxlength is generally not recommended. A main issue was (and possibly still is) that as the user can keep entering characters, these characters are read by the screen reader, but there is no indication that they aren't being added to the input. There were a lot of discussions about this 5 and 10 years ago. Letting the user add more than the max characters but indicating that they're beyond the limit, color, and not allowing submission (i.e. Twitter, Mastodon, etc. UI pattern) are better usability. Ex. https://heymichellemac.com/design-pattern-character-limits. So maybe omit this or downplay it because we don't want to be recommending it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've downplayed it a bit — removed some of the instances from the examples, and removed language that says it is useful.


#### HTML

The HTML contains two sets of `<select>` elements: one with `field-sizing: content` applied, and one without, allowing you to see the difference (though the effect may be less obvious than on text fields). Each set includes one drop-down menu type and one multiline listbox type (with the [`multiple`](/en-US/docs/Web/HTML/Element/select#multiple) attribute set).
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add a note about why we aren't using labels.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

chrisdavidmills and others added 7 commits April 15, 2024 21:29
Co-authored-by: Dipika Bhattacharya <dipika@foss-community.org>
Co-authored-by: Dipika Bhattacharya <dipika@foss-community.org>
Co-authored-by: Estelle Weyl <estelle@openwebdocs.org>
Co-authored-by: Estelle Weyl <estelle@openwebdocs.org>
Co-authored-by: Estelle Weyl <estelle@openwebdocs.org>
@chrisdavidmills chrisdavidmills merged commit c88c96a into mdn:main Apr 15, 2024
8 checks passed
@chrisdavidmills chrisdavidmills deleted the field-sizing branch April 15, 2024 21:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Content:CSS Cascading Style Sheets docs Content:HTML Hypertext Markup Language docs size/m [PR only] 51-500 LoC changed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants