Skip to content

Commit 4000150

Browse files
author
Ayesha Mazumdar
authored
fix(dueling-picklist): New class 'slds-dueling-picklist__column_responsive' for responsive dueling picklists (#3142)
1 parent 1b8e6b8 commit 4000150

File tree

7 files changed

+166
-5
lines changed

7 files changed

+166
-5
lines changed

ui/components/dueling-picklist/__tests__/__snapshots__/renders_a_responsive_dueling_picklist.json

Lines changed: 61 additions & 0 deletions
Large diffs are not rendered by default.

ui/components/dueling-picklist/__tests__/__snapshots__/renders_a_responsive_non_reorderable_dueling_picklist.json

Lines changed: 52 additions & 0 deletions
Large diffs are not rendered by default.

ui/components/dueling-picklist/__tests__/index.spec.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,5 +49,15 @@ it('renders a dueling picklist with a dropped option', () =>
4949
it('renders a dueling picklist with an option that was moved to another list', () =>
5050
matchesMarkupAndStyle(<MultiSelect dataSet={MovedInSnapShot} />));
5151

52+
it('renders a responsive dueling picklist', () =>
53+
matchesMarkupAndStyle(
54+
<MultiSelect dataSet={DefaultSnapShot} isResponsive />
55+
));
56+
57+
it('renders a responsive non-reorderable dueling picklist', () =>
58+
matchesMarkupAndStyle(
59+
<MultiSelect dataSet={DefaultSnapShot} noReorder isResponsive />
60+
));
61+
5262
it('renders a view mode of dueling picklist', () =>
5363
matchesMarkupAndStyle(<MultiSelectViewMode />));

ui/components/dueling-picklist/base/_index.scss

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,24 @@
3535
}
3636
}
3737

38+
/**
39+
* @summary Changes the layout of the dueling picklist to be responsive
40+
*
41+
* @selector .slds-dueling-list__column_responsive
42+
* @restrict .slds-dueling-list__column
43+
*/
44+
.slds-dueling-list__column_responsive {
45+
flex: 0 1 $size-small;
46+
flex-wrap: wrap;
47+
overflow: hidden;
48+
min-width: $size-xx-small;
49+
50+
.slds-dueling-list__options {
51+
width: auto;
52+
max-width: $size-small;
53+
}
54+
}
55+
3856
/**
3957
* @summary Bounding visual container for listbox of options
4058
*

ui/components/dueling-picklist/base/example.jsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,11 @@ export let states = [
6767
label: 'No Reordering',
6868
element: <MultiSelect dataSet={DefaultSnapShot} noReorder />
6969
},
70+
{
71+
id: 'responsive-no-reordering-dueling-picklist',
72+
label: 'Responsive No Reordering',
73+
element: <MultiSelect dataSet={DefaultSnapShot} noReorder isResponsive />
74+
},
7075
{
7176
id: 'view-mode-dueling-picklist',
7277
label: 'View Mode',

ui/components/dueling-picklist/docs.mdx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,15 @@ This component is essentially 2 ARIA listboxes side by side, so we follow the [A
4343
- `space` toggles "Drag and Drop" mode. When in "Drag and Drop" mode:
4444
- `up` and `down` arrows move the selected items _within_ the current list
4545

46+
## Responsive
47+
48+
To make the dueling picklist responsive or use it within narrow regions, apply the class `slds-dueling-picklist__column_responsive` to the `<div>`s with class `slds-dueling-picklist__column` that contain options (not the columns that only contain buttons). Any items longer than the space available will truncate with ellipses.
49+
50+
<Example title="Dueling Picklist">
51+
<CodeView>
52+
<MultiSelect dataSet={CountriesSnapshot} noReorder isResponsive />
53+
</CodeView>
54+
</Example>
4655

4756
## Edit Mode
4857

ui/components/dueling-picklist/index.js

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ export const MultiSelect = props => {
2525
</div>
2626
<SelectionGroup
2727
disabled={props.disabled}
28+
isResponsive={props.isResponsive}
2829
group={props.dataSet.selectionGroups[0]}
2930
/>
3031
<MoveButtons
@@ -35,6 +36,7 @@ export const MultiSelect = props => {
3536
/>
3637
<SelectionGroup
3738
disabled={props.disabled}
39+
isResponsive={props.isResponsive}
3840
group={props.dataSet.selectionGroups[1]}
3941
/>
4042
{!props.noReorder && (
@@ -99,7 +101,11 @@ const MoveButtons = props => {
99101
const SelectionGroup = props => {
100102
const groupLabelID = _.uniqueId('label-');
101103
return (
102-
<div className="slds-dueling-list__column">
104+
<div
105+
className={classNames('slds-dueling-list__column', {
106+
'slds-dueling-list__column_responsive': props.isResponsive
107+
})}
108+
>
103109
<span className="slds-form-element__label" id={groupLabelID}>
104110
{props.group.label}
105111
</span>
@@ -700,7 +706,7 @@ export const CountriesSnapshot = {
700706
isGrabbed: false
701707
},
702708
{
703-
text: 'Turkish',
709+
text: 'Tobagonian Creole English',
704710
tabIndex: -1,
705711
isSelected: false,
706712
isGrabbed: false
@@ -760,7 +766,7 @@ export const SelectedCountriesSnapshot = {
760766
isGrabbed: false
761767
},
762768
{
763-
text: 'Turkish',
769+
text: 'Tobagonian Creole English',
764770
tabIndex: -1,
765771
isSelected: false,
766772
isGrabbed: false
@@ -820,7 +826,7 @@ export const MultipleSelectedCountriesSnapshot = {
820826
isGrabbed: false
821827
},
822828
{
823-
text: 'Turkish',
829+
text: 'Tobagonian Creole English',
824830
tabIndex: -1,
825831
isSelected: false,
826832
isGrabbed: false
@@ -868,7 +874,7 @@ export const DroppedCountriesSnapshot = {
868874
isGrabbed: false
869875
},
870876
{
871-
text: 'Turkish',
877+
text: 'Tobagonian Creole English',
872878
tabIndex: -1,
873879
isSelected: false,
874880
isGrabbed: false

0 commit comments

Comments
 (0)