-
Notifications
You must be signed in to change notification settings - Fork 83
fix(ASSETS-17276):Form elements must have labels. #278
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
Open
ionelc-ensemble
wants to merge
1
commit into
adobe:master
Choose a base branch
from
ionelc-ensemble:issue/ASSETS-17276-creative-rating-input-label
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adding a default generic accessibility name for this control will hide the issue an prevent automated testing from detecting cases where a label has not been provided for the control. The appropriate way to label this control would be to add a
labelledBy
attribute to the<coral-numberinput />
element that references the DOM element that labels the control, as demonstrated in each example on https://opensource.adobe.com/coral-spectrum/examples/#numberinput. This is not an issue with thecoral-component-numberinput
, but rather with the instance where it is being used in AEM.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for clarifying @majornista. Indeed the instance where this
coral-component-numberinput
is used is different from other instances by not having a label for the input, otherwise anaria-labelledby
attributed is added automatically. Screenshots from the same page but different tabs, with and without label:It's why I opted for adding a title but you are right about the issue that it would hide.
In this case should this be marked as not an issue?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not an issue for Coral Spectrum, but it is an issue for the number input instance for the Creative Rating within AEM. The fix would be to add a unique
id
attribute to the "Creative Rating" heading preceding thecoral-numberinput
and then use thatid
as the value for thelabelledBy
attribute on thecoral-numberinput
instance.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ionelc-ensemble Here's a brief explanation of why we use
labelledBy
andlabelled
to provide labels to controls in CoralUI and Coral-Spectrum. Coral components are built using web components specification but only implement Custom Elements v1. For composite controls like thecoral-numberinput
, we can't simply addaria-label
,aria-labelledby
, or expect to assign anid
, to be referenced using afor
attribute on a label, to thecoral-numberinput
element because we would only label the container and not the actualinput
that gets rendered within it. In order to ensure thataria-label
oraria-labelledby
get added to the appropriate rendered html element, the BaseFormField defineslabelled
,labelledBy
anddescribedBy
attributes to use instead ofaria-label
,aria-labelledby
, oraria-describedby
. These setters locate the appropriate labellable element with the rendered component and addaria-label
,aria-labelledby
, oraria-describedby
to provide an accessible name to the control. I hope this makes sense and helps.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@majornista that was helpful, thanks for taking the time to show the bigger picture.
While adding an ID to the 'Creative Rating' heading however, I got to the root of the issue: the rating input was missing the string for the label. Added that and everything fell into place.
My concern now is whether that rating input SHOULD be without a label for any reason, in which case I will continue working for a fix here.
Else will closed this PR after validating the new fix that adds the label string