Re: [csswg-drafts] [css-ui] ? Allow <textarea> to be sized by contents. (#7542)

Since this actually affects how the intrinsic size is used, why isn't the property named _intrinsic-size_?

In other parts of CSS, resizing according to content in one or more axes is the _default_ mode. Having a new property called `field-sizing` which only applies to form controls and has different behaviour to input / select (auto-resize in inline direction) vs textarea (auto-resize in block direction) also feels too magical and is introducing even more specific sizing behaviour.

It also doesn't address the pain points around special sizing behaviour for other replaced elements like img and video which have their own width and height even when you set `display: block`, nor for iframes which have this weird 300px x 150px size even if you set it to `display: block`.

I suggest this property be called `intrinsic-size`, and instead of `content` and `fixed`, it should be `none` and `auto`.

When `none` is coupled with `display: block`, it causes all replaced elements and form controls to assume the width of the container and resize its height to fit the content (if `height` is `auto`). This would disable the default width of iframe and textarea of 300px, and cause video, img, select, input to actually behave like block elements everywhere else in CSS, and fill all of the available width.

(For iframe maybe dynamically resizing according to content is too difficult to implement and/or introduces security risks. But at least the width should behave like all other display: block elements. Potentially the height should just resolve to 0px as if there were no contents?)

When coupled with `display: inline`,  this will cause the textarea, video, img, select or input to shrink according to its content (i.e. use the natural width as it is for video and img, and just resize and overflow for textarea, select or input). 

(For iframe it may not be feasible to actually resize it according to its contents. Potentially it should just resolve to 0px as if there were no contents?)

When `intrinsic-size` is set to `auto`, all the crazy sizing behaviours for img, video, input, select, textarea and iframe are kept as they are currently defined, with img and video sized to their natural width, input, select and textarea to platform defined widths, and iframe to be 300px x 150px, regardless of whether they are block or inline.

-- 
GitHub Notification of comment by hfhchan
Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/7542#issuecomment-1758214019 using your GitHub account


-- 
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config

Received on Wednesday, 11 October 2023 18:08:00 UTC