Skip to content

Commit 3556b26

Browse files
committed
fix(dueling picklist): Remove required in favour of locked options in the listbox with updated visuals
1 parent bf965db commit 3556b26

File tree

2 files changed

+31
-14
lines changed

2 files changed

+31
-14
lines changed

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import React from 'react';
55
import {
66
MultiSelect,
77
DefaultSnapShot,
8-
RequiredSnapShot,
8+
LockedSnapShot,
99
DisabledSnapShot,
1010
SelectedSnapShot,
1111
MultiSelectedSnapShot,
@@ -23,8 +23,8 @@ export default <MultiSelect dataSet={DefaultSnapShot} />;
2323
export let states = [
2424
{
2525
id: 'required-dueling-picklist',
26-
label: 'Required',
27-
element: <MultiSelect dataSet={RequiredSnapShot} />
26+
label: 'Locked',
27+
element: <MultiSelect dataSet={LockedSnapShot} />
2828
},
2929
{
3030
id: 'disabled-dueling-picklist',

ui/components/dueling-picklist/index.js

Lines changed: 28 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ const SelectionGroup = props => {
9090
disabled={props.disabled}
9191
options={props.group.options}
9292
ariaLabelledby={groupLabelID}
93+
listboxLabel={props.group.label}
9394
/>
9495
</div>
9596
);
@@ -111,7 +112,11 @@ const ListBox = props => (
111112
role="listbox"
112113
>
113114
{props.options.map(option => (
114-
<Option key={_.uniqueId('cell-resize-handle-')} option={option} />
115+
<Option
116+
key={_.uniqueId('cell-resize-handle-')}
117+
option={option}
118+
listboxLabel={props.listboxLabel}
119+
/>
115120
))}
116121
</ul>
117122
</div>
@@ -121,7 +126,7 @@ const Option = props => (
121126
<li role="presentation" className="slds-listbox__item">
122127
<div
123128
className={classNames(
124-
'slds-listbox__option slds-listbox__option_plain slds-media',
129+
'slds-listbox__option slds-listbox__option_plain slds-media slds-media_small slds-media_inline',
125130
{
126131
'slds-is-grabbed': props.option.isGrabbed,
127132
'slds-is-selected': props.option.isSelected
@@ -132,14 +137,26 @@ const Option = props => (
132137
role="option"
133138
tabIndex={props.option.tabIndex}
134139
>
135-
<span className="slds-truncate" title={props.option.text}>
136-
{props.option.text}
137-
{props.option.required ? (
138-
<abbr className="slds-required" title="required">
139-
*
140-
</abbr>
141-
) : null}
140+
<span className="slds-media__body">
141+
<span className="slds-truncate" title={props.option.text}>
142+
{props.option.text}
143+
</span>
142144
</span>
145+
{props.option.locked && (
146+
<span className="slds-media__figure slds-media__figure_reverse">
147+
<span className="slds-icon_container" title="Locked item">
148+
<SvgIcon
149+
className="slds-icon slds-icon_x-small slds-icon-text-default"
150+
sprite="utility"
151+
symbol="lock"
152+
/>
153+
<span className="slds-assistive-text">
154+
{' '}
155+
: item cannot be removed from {props.listboxLabel}
156+
</span>
157+
</span>
158+
</span>
159+
)}
143160
</div>
144161
</li>
145162
);
@@ -256,7 +273,7 @@ export const DisabledSnapShot = {
256273
]
257274
};
258275

259-
export const RequiredSnapShot = {
276+
export const LockedSnapShot = {
260277
liveRegionText: '',
261278
optionDragLabel:
262279
'Press space bar when on an item, to move it within the list. CMD plus left and right arrow keys, to move items between lists. Required items must remain in the second category.',
@@ -298,7 +315,7 @@ export const RequiredSnapShot = {
298315
tabIndex: 0,
299316
isSelected: false,
300317
isGrabbed: false,
301-
required: true
318+
locked: true
302319
},
303320
{
304321
text: 'Option 5',

0 commit comments

Comments
 (0)