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

Dirname should work with more input types #9225

Closed
r12a opened this issue Apr 27, 2023 · 5 comments · Fixed by #9490
Closed

Dirname should work with more input types #9225

r12a opened this issue Apr 27, 2023 · 5 comments · Fixed by #9490
Labels
addition/proposal New features or enhancements i18n-tracker Group bringing to attention of Internationalization, or tracked by i18n but not needing response. needs implementer interest Moving the issue forward requires implementers to express interest topic: forms

Comments

@r12a
Copy link

r12a commented Apr 27, 2023

I'm wondering why tel and hidden types are excluded from working with dirname.

I'm inclined to think that it would be particularly useful to pass on information that a telephone number should be stored or handled as a LTR sequence so that it can be correctly rendered elsewhere – telephone numbers are one of the key areas where users struggle with bidi rendering, because they typically only include weak directional characters.

I could also imagine text being passed to a database via a hidden input element that may be directionally-sensitive, in which case dirname may be useful.

This may also apply to email and url types. If a person's email address is mostly in Arabic (پبتث@شجغ.sa), it may be good to store metadata about the direction set by the user when typing in the address, so that it can be rendered right to left in another location. Such an address will look very different in a LTR context.

A field set to RTL by the user while typing their email address:
Screenshot 2023-04-25 at 16 42 47

The same email address retrieved from a database and rendered without correction of the base direction in a LTR page:
Screenshot 2023-04-25 at 16 43 03

@r12a r12a added the i18n-tracker Group bringing to attention of Internationalization, or tracked by i18n but not needing response. label Apr 27, 2023
@annevk annevk added addition/proposal New features or enhancements needs implementer interest Moving the issue forward requires implementers to express interest topic: forms labels Apr 27, 2023
@annevk
Copy link
Member

annevk commented Apr 27, 2023

cc @whatwg/forms

@zcorpan
Copy link
Member

zcorpan commented May 2, 2023

https://html.spec.whatwg.org/#bidi-rendering says

Input fields (i.e. textarea elements, and input elements when their type attribute is in the Text, Search, Telephone, URL, or Email state) are expected to present an editing user interface with a directionality that matches the element's 'direction' property.

While this doesn't say that users are expected to be able to change the directionality for these elements, it seems inconsistent to support author-provided directionality but only allow users to change directionality for a subset, or to allow changing directionality but then not submitting it with dirname.

hidden may be useful as a way of submitting contenteditable elements.

Relatedly, https://html.spec.whatwg.org/#persisted-user-state-restoration also says to (optionally) restore dir attribute values in session restore:

Optionally, update other aspects of entry's document and its rendering, for instance values of form fields, that the user agent had previously recorded in entry's persisted user state.

Note: This can even include updating the dir attribute of textarea elements or input elements whose type attribute is in either the Text state or the Search state, if the persisted state includes the directionality of user input in such controls.

This note should probably be updated if we allow dirname on more elements.

@zcorpan
Copy link
Member

zcorpan commented Jul 5, 2023

PR at #9490

Is there interest from WebKit and Chromium?

@annevk
Copy link
Member

annevk commented Jul 6, 2023

Yeah this seems reasonable.

annevk added a commit that referenced this issue Jul 24, 2023
Also consistently sort the Telephone state before the URL state.

Fixes #9225.

Co-authored-by: Anne van Kesteren <annevk@annevk.nl>
@r12a
Copy link
Author

r12a commented Jul 25, 2023

Many thanks!

rubberyuzu pushed a commit to rubberyuzu/html that referenced this issue Aug 25, 2023
Also consistently sort the Telephone state before the URL state.

Fixes whatwg#9225.

Co-authored-by: Anne van Kesteren <annevk@annevk.nl>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
addition/proposal New features or enhancements i18n-tracker Group bringing to attention of Internationalization, or tracked by i18n but not needing response. needs implementer interest Moving the issue forward requires implementers to express interest topic: forms
Development

Successfully merging a pull request may close this issue.

3 participants