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

The "value" attribute of <input type="button"> should be directionality-capable #3330

Closed
jfkthame opened this issue Jan 6, 2018 · 11 comments · Fixed by #9689
Closed

The "value" attribute of <input type="button"> should be directionality-capable #3330

jfkthame opened this issue Jan 6, 2018 · 11 comments · Fixed by #9689
Labels
i18n-tracker Group bringing to attention of Internationalization, or tracked by i18n but not needing response. normative change topic: forms

Comments

@jfkthame
Copy link

jfkthame commented Jan 6, 2018

In the list of "directionality-capable attributes" at [1], I was surprised to find that the "value" attribute of was not included, even though this attribute's text is clearly expected to be rendered.

A simple testcase

data:text/html;charset=utf-8,<input dir="auto" type="button" value="العربي Latin">

(where the Arabic text logically precedes the Latin) shows the button label rendered with LTR directionality (the Arabic text appears on the left, the Latin on the right) in both Firefox and Safari; however, in Chrome it renders with RTL directionality (Arabic on the right, Latin on the left).

AFAICS, this is a Chrome bug w.r.t. the current spec, as this attribute is not listed as directionality-capable, but I think it would make more sense from an author's point of view to align the spec (and other browsers) with Chrome's behavior here.

See also the Firefox bug report https://bugzilla.mozilla.org/show_bug.cgi?id=1428316.

[1] https://html.spec.whatwg.org/multipage/dom.html#directionality-capable-attribute

@annevk annevk added the i18n-tracker Group bringing to attention of Internationalization, or tracked by i18n but not needing response. label Jan 6, 2018
@annevk
Copy link
Member

annevk commented Jan 6, 2018

Is it problematic if we apply this to all types of input elements or should we list the ones this should work for? E.g., it does not make much sense for <input type=date>, but it wouldn't be observable either, so probably fine?

cc @whatwg/i18n

@jfkthame
Copy link
Author

jfkthame commented Jan 6, 2018

I'd guess that applying it to all types of input is probably fine. Interestingly, further testing in Firefox shows that value does seem to be treated as directionality-capable for some types of input (any of those that simply render as a text field, I think), though the spec doesn't support that AFAICS; it says their placeholder (if present) would be directionality-capable, but not value.

@annevk
Copy link
Member

annevk commented Jan 6, 2018

Ah, I think currently it follows from https://html.spec.whatwg.org/multipage/dom.html#the-directionality (note how that refers to the "value" concept) coupled with https://html.spec.whatwg.org/multipage/dom.html#directionality-of-the-attribute. That does currently exclude input elements in the Button state though (and Reset/Submit Button).

@aphillips
Copy link
Contributor

aphillips commented Jan 6, 2018

@annevk Values such as number, date, etc. shouldn't be directionality-capable since it is their local representation that's meant to be displayed and the value is a locale-neutral wire format.

The button case looks like an oversight to me: the value is meant to be displayed. What's more 4.10.5.1.21 disallows dirname on type=button, so the direction applied by dir=auto can't be discovered server-side.

@annevk
Copy link
Member

annevk commented Jan 6, 2018

So let's see. We want to change:

If the element is an input element whose type attribute is in the Text, Search, Telephone, URL, or E-mail state, and the dir attribute is in the auto state

To include Submit Button, Reset Button, and Button.

And we want to allow dirname on those three button states as well.

Note that we don't allow dirname for Telephone, URL, and E-mail. I guess that's fine?

@aphillips
Copy link
Contributor

Note that we don't allow dirname for Telephone, URL, and E-mail. I guess that's fine?

I think that's right. I guess technically they could be directional, but in practice they aren't. IIRC, Adlam is the only numbering system where the digits are RTL and I don't think that'll be used much for phone numbers?

@annevk
Copy link
Member

annevk commented Sep 1, 2023

On reflection, I think my conclusion surrounding applying dirname to buttons is wrong as dirname is for end-user-supplied content and button values are supplied by the web developer. So this should be exclusively about updating the "directionality" algorithm.

cc @r12a

@aphillips
Copy link
Contributor

The button values are supplied by the web developer, but when submitted the button's value looks just like any other value. While the web developer might own the receiving process, it's probably easier and better if the directionality of all fields work in the same way, rather than some requiring the developer to remember what direction was applied to a control like a button. (Also, many web applications are localized, often dynamically, so that button's direction will vary according to the locale used to compose the page--and not always derivable from the locale itself)

@annevk
Copy link
Member

annevk commented Sep 1, 2023

Thanks, that's compelling. I've folded that improvement into #9669 so we can keep this focused on "directionality".

Two outstanding questions for this issue:

  • Should the value of a button should influence the directionality of the button itself or should it just influence the directionality of the attribute? I'm guessing the button itself makes the most sense.
  • Should we reconsider what we do for Telephone here: https://html.spec.whatwg.org/#the-directionality? It seems like such a weird special case.

cc @fantasai @rniwa

@aphillips
Copy link
Contributor

aphillips commented Sep 1, 2023

I agree that Telephone kind of "sticks out funny" and probably should not be an exception.

I played with it here a bit.

I noticed a bug in FF: dir=auto doesn't work on the button's value (works in Chrome). My tendency is to think that the value should influence the button, but I'm not sure if there might be weird side effects.

@annevk
Copy link
Member

annevk commented Sep 1, 2023

The main effect would be whether :dir ends up matching differently because of it, as far as I know. And I tend to agree it's better if it does.

https://www.w3.org/Bugs/Public/show_bug.cgi?id=17835 seems to cover the telephone change based on an extensive discussion with @aharon-lanin. I guess that argues for keeping it, even if it's a little weird.

(This also makes me wonder if custom elements should be able to set their own directionality, but that might be some quite advanced bit of technology that's not really needed in practice.)

annevk added a commit that referenced this issue Sep 5, 2023
Include the input Password state in the auto directionality algorithm to achieve consistency with input elements where the dirname attribute will apply as per the discussion in # #9669.

Also include the input buttons, except for the Image Button. Notably this does not include the button element as there the contents of the element and the value are distinct concepts (value is only used for submission and not for rendering).

Tests: ...

Fixes #3330.
annevk added a commit that referenced this issue Oct 6, 2023
Include the input Password state in the auto directionality algorithm to achieve consistency with input elements where the dirname attribute will apply as per the discussion in # #9669.

Also include the input buttons, except for the Image Button. Notably this does not include the button element as there the contents of the element and the value are distinct concepts (value is only used for submission and not for rendering).

Tests: ...

Fixes #3330.
annevk added a commit that referenced this issue Oct 24, 2023
This makes two changes:

* Applies the auto directionality algorithm to Hidden, Password, Submit Button, Reset Button, and Button input elements.
* Adds support for the dirname attribute to Password and Submit Button input elements.

And it uses a shared concept between these two features so they will no longer diverge going forward. (The concept can still be shared despite Reset Button and Button input elements not supporting the dirname attribute as the concept is only consulted in form submission where those elements have already been filtered out.)

Tests: web-platform-tests/wpt#42427

Fixes #3330 and fixes #9669.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
i18n-tracker Group bringing to attention of Internationalization, or tracked by i18n but not needing response. normative change topic: forms
Development

Successfully merging a pull request may close this issue.

3 participants