-
Notifications
You must be signed in to change notification settings - Fork 693
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
[css-ui] Optionally wrap input
content instead of causing invisible overflow
#10019
Comments
It's not entirely clear if you want a single-line field with visible scrollbars, or a multi-line field with implicit submission for the enter key. Note that user agents aren't required to have implicit submission for |
See the attached screenshot, I want that. I want a field that wraps its content, but doesn't allow line breaks (via key press, paste or |
I don't really get the point of forbidding line breaks if the text can wrap into multiple lines anyways? The Google textbox from your image accepts newlines (since it's a |
Wrapping is not the same as multiple lines. Wrapping is just a way to deal with overflow. Can we agree that single-line |
I think this issue should be narrowed into a feature request of an auto-wrapping And the request is to relax this particular restriction in css-ui on single line inputs:
|
textarea
or auto-wrapping input
input
content instead of causing invisible overflow
input
content instead of causing invisible overflowinput
content instead of causing invisible overflow
@xiaochengh however you frame it, it requires altering a core behavior of a field type:
The difference is that a wrapping So maybe: input {
text-overflow: wrap;
} |
I still think
And Btw should this issue be discussed at @whatwg/html instead? Because I feel like an auto-wrapping input is hardly useful without 2, and if we want to introduce a behavioral change, we should go to whatwg first. CSS is mostly for presentational topics. |
If you want to go with
Google Search's behavior would be achieved via: input:focus {
text-wrap: wrap;
field-sizing: content;
max-height: 4lh;
} which would cause the input field to revert to single-line when not focused. |
Perspective from a developer: We have a nice form abstraction solution, that supports a variety of types extending from the The problem? Switching to textarea is non-trivial (and causes a loss of functionality for non-JS users), as textarea doesn't support different Consider this a voice in favor of allowing developers to turn on text wrapping on inputs. |
The correct element to handle single-line text inputs is
<input type="text">
, however its default behavior for overflowing text is to make the field "invisibly scrollable". This has awful usability if the text tends to be longer, because the user cannot see the entire text at once and there's no scrollbar.This leads to authors defaulting to
textarea
even if they want to preserve the the "single-line" input type.A notable example of this is Google Search:
You want to allow long input, but also you want to preserve the ability to submit text with Enter.
The
field-sizing
proposal is another key of this puzzle, also seen on Google Search.The text was updated successfully, but these errors were encountered: