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

feat(Dropdown): add checkable and checkableIndicator prop#1738

Merged
mnajdova merged 13 commits intomasterfrom
feat/dropdown-selected-checkmark
Aug 16, 2019
Merged

feat(Dropdown): add checkable and checkableIndicator prop#1738
mnajdova merged 13 commits intomasterfrom
feat/dropdown-selected-checkmark

Conversation

@mnajdova
Copy link
Contributor

@mnajdova mnajdova commented Jul 31, 2019

We have a requirement for Teams theme for adding checkmark icon in the selected dropdown item. We have several options:

  1. add selectedIndicator icon shorthand prop in the Dropdown, for allowing setting checkmark on the selected drop down item:

image

  1. Add checkable & checkableIndicator props on the Dropdown & DropdownItem - similar to the clearable and clearableIndicator that we already have (thanks @layershifter for the proposal)

  2. Adding endMedia prop in the Dropdown Item as it is already a list item, and users can use it if they want to add some icon when the item is selected.

We need to decide on a common pattern for these things. In the Input, we have only the clearable boolean prop, so we have no way of customizing that slot. In the Dropdown together with the clearable we have the clearableIndicator. As we tend to say that every slot in the Stardust components can be customized, I believe we need to have slots for these things as well, although that they have some defaults.

@codecov
Copy link

codecov bot commented Jul 31, 2019

Codecov Report

Merging #1738 into master will decrease coverage by <.01%.
The diff coverage is 83.33%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1738      +/-   ##
==========================================
- Coverage   69.79%   69.78%   -0.01%     
==========================================
  Files         872      872              
  Lines        7498     7503       +5     
  Branches     2204     2207       +3     
==========================================
+ Hits         5233     5236       +3     
- Misses       2257     2259       +2     
  Partials        8        8
Impacted Files Coverage Δ
...es/teams/components/Dropdown/dropdownItemStyles.ts 7.14% <0%> (-1.2%) ⬇️
...ges/react/src/components/Dropdown/DropdownItem.tsx 77.77% <100%> (+6.34%) ⬆️
...ackages/react/src/components/Dropdown/Dropdown.tsx 88.25% <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 99840c2...ab89e28. Read the comment docs.

styles: styles.content,
},
})}
endMedia={
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is different then how the rest of the elements are created and where the styles are applied, but there are issues with the height if we don't provide these styles.. I am open for other ideas...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@layershifter
Copy link
Member

Atlaskit

https://atlaskit.atlassian.com/packages/core/select
Please check Named Exports:

image
image

BlueprintJS

MultiSelect there has similar idea:
https://blueprintjs.com/docs/#select/multi-select

image

AntDesign

https://ant.design/components/select/
Check multiple selection.

image

@mnajdova mnajdova changed the title feat(Dropdown): add selectedIndicator prop feat(Dropdown): add checkable & checkableIndicator props Aug 1, 2019
@mnajdova mnajdova changed the title feat(Dropdown): add checkable & checkableIndicator props feat(Dropdown): add checkable and checkableIndicator prop Aug 1, 2019
@kolaps33
Copy link
Collaborator

kolaps33 commented Aug 2, 2019

We will need to set aria-selected on selected option:
Based on example 2 on this page:
https://www.w3.org/TR/wai-aria-practices-1.1/examples/listbox/listbox-rearrangeable.html

searchQuery: PropTypes.string,
searchInput: customPropTypes.itemShorthand,
toggleIndicator: customPropTypes.itemShorthand,
toggleIndicator: customPropTypes.itemShorthandWithoutJSX,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed prop type

}),
checkableIndicator: ({ variables: v }) => ({
position: 'relative',
left: pxToRem(3),
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The padding on the DropdownItem is 11px, but the icon should be 8px from the right border, that's why we need styles

Co-Authored-By: Oleksandr Fediashov <olfedias@microsoft.com>
@mnajdova mnajdova merged commit fc927f0 into master Aug 16, 2019
@delete-merged-branch delete-merged-branch bot deleted the feat/dropdown-selected-checkmark branch August 16, 2019 10:54
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants