Skip to content
This repository was archived by the owner on Mar 4, 2020. It is now read-only.

feat(Label): integrate with Dropdown#1446

Merged
silviuaavram merged 18 commits intomasterfrom
feat-dropdown-form-field
Jun 11, 2019
Merged

feat(Label): integrate with Dropdown#1446
silviuaavram merged 18 commits intomasterfrom
feat-dropdown-form-field

Conversation

@silviuaavram
Copy link
Collaborator

Replacing #1372 with this approach.

Since both the triggerButton/searchInput need to be labelled, I passed the id of the label to the Dropdown via labelId and handled it there.

Added example of usage.

@codecov
Copy link

codecov bot commented Jun 3, 2019

Codecov Report

Merging #1446 into master will increase coverage by <.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1446      +/-   ##
==========================================
+ Coverage   73.47%   73.47%   +<.01%     
==========================================
  Files         807      807              
  Lines        6081     6082       +1     
  Branches     1768     1750      -18     
==========================================
+ Hits         4468     4469       +1     
  Misses       1608     1608              
  Partials        5        5
Impacted Files Coverage Δ
...ackages/react/src/components/Dropdown/Dropdown.tsx 88.57% <100%> (+0.02%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update b0587b2...435a2c5. Read the comment docs.

@silviuaavram silviuaavram added accessibility All the Accessibility tasks and bugs should be tagged with this. 🚀 ready for review labels Jun 4, 2019
*/
itemToString?: (item: ShorthandValue) => string

labelId?: string
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we need this prop? can't we just use 'aria-labelledby' attribute directly?

It also misses documentation

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oups, will add documentation!

Maybe because we need to compute aria-labelledby from that (in case of the trigger button, we also add its own id). Also because it is used in two places: button/input and ul. I think it's better this way. We will have it computed in the behavior in the future. Will ask for more opinions on this.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, let's see what others say
@layershifter @kuzhelov @mnajdova

label: { content: `Your best friend's name is:`, id: labelId },
name: 'chooseFriend',
key: 'choose-friend',
required: true,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove it, it passes required to div:

<div class="ui-dropdown ui-box" required="" name="chooseFriend" />

const labelId = 'choose-friend-label'
const fields = [
{
label: { content: `Your best friend's name is:`, id: labelId },
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am surprised with generated markup, is it valid? I expect:

<label for="favoritefood">Favorite food</label> <!-- <<== `for` is used -->
<select name="favoritefood" id="favoritefood">
  <option>Cheese</option>
</select>

We have:

<label class="ui-text" dir="auto" id="choose-friend-label">Your best friend&#x27;s name is:</label>
<div class="ui-dropdown ui-box" required="" name="chooseFriend" />

And if we will pass id on root:

 <label class="ui-text" dir="auto" for="choose-friend-label" id="choose-friend-label">

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

@layershifter layershifter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't have better ideas than labelId right now. Please also update PR description: it integrates Dropdown and Form.Field.

this.handleTriggerButtonKeyDown(e, rtl)
},
'aria-label': content,
'aria-label': undefined,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if somebody provides aria-label should not we apply it to the trigger or to the input as well? the same for aria-describedby

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see it as being suggested by ARIA, and if the user wants to do his own magic with label and describedby he can always use the slots.

But if you think we should handle it by default then we can create a new task.

@silviuaavram silviuaavram merged commit aac7df2 into master Jun 11, 2019
@delete-merged-branch delete-merged-branch bot deleted the feat-dropdown-form-field branch June 11, 2019 12:13
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

accessibility All the Accessibility tasks and bugs should be tagged with this. 🚀 ready for review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants