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

Read-only Field component #7962

Open
rolfsmeds opened this issue Oct 9, 2024 · 3 comments
Open

Read-only Field component #7962

rolfsmeds opened this issue Oct 9, 2024 · 3 comments
Labels
component-idea enhancement New feature or request

Comments

@rolfsmeds
Copy link
Contributor

rolfsmeds commented Oct 9, 2024

A component for non-editable key-value pairs consisting of a label and a value, for use e.g. in read-only forms.

  • Labels above and aside variants
  • Databindable (like input fields)
  • Nice-to-have: built-in formatting support for numbers, datetime...)

Labels above:
Image
(This should work nicely out of the box in FormLayout, and align appropriately with input fields)

Labels aside:
Image
(note: labels-aside mode should be considered together with labels-aside support in input fields)

Semantics

Could be as simple as

  • ReadonlyField root (generic)
    • label
    • span (value), with aria-labelledby reference to label

Or we could consider using <data> element for the value, and have the possibility to provide a machine-readable value in addition to the rendered value, possibly also switching that to a <time> element for datetime values.

Open questions

Is ReadOnlyField / vaadin-read-only-field a good name?

Could consider having a secondary text / slot, somewhat similar to the helper-text below input fields, e.g. for use cases such as this
Image

@rolfsmeds rolfsmeds added enhancement New feature or request component-idea labels Oct 9, 2024
@DiegoCardoso
Copy link
Contributor

I was playing around with this proposal to see if I understood how the component should behave in terms of accessibility. So, I came up with this prototype (https://codepen.io/diegocardoso/pen/BaXpyWZ). What I could see is that if aria-labelledby would probably need to reference both the <label> and the <span> elements, otherwise it will be skipped in the announcement. Here's a recording of the different approaches in the test using VO+Safari:

read-only-sr.mp4

I used role=group in some cases to see if it would make any difference, but nothing could be noted for VoiceOver. Not sure if there's a better role to be used instead (or none).

@rolfsmeds
Copy link
Contributor Author

Ah, indeed, I added that "with aria-labelledby reference to label" to the wrong "node" in the DOM proposal, it should be on the span.

@DiegoCardoso
Copy link
Contributor

Even in that case, if the <span> has an aria-labelledby attribute, its content ends up ignored in favor of the element it references. So it would need to reference to itself.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component-idea enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants