Skip to content

Commit 79c5729

Browse files
Revert "(Picklist, Lookup): use inputs with type="text" for better a11y"
This reverts commit 4adb664.
1 parent b0bebd7 commit 79c5729

File tree

2 files changed

+15
-17
lines changed

2 files changed

+15
-17
lines changed

src/scripts/Lookup.tsx

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -152,18 +152,17 @@ const LookupSelectedState: FC<LookupSelectedStateProps> = ({
152152
size='small'
153153
/>
154154
)}
155-
<input
156-
type='text'
157-
readOnly
158-
disabled={disabled}
159-
value={selected.label}
155+
<button
156+
type='button'
160157
role='combobox'
161158
tabIndex={disabled ? -1 : 0}
162159
className='slds-input_faux slds-combobox__input slds-combobox__input-value'
163160
aria-controls={listboxId}
164161
aria-haspopup='listbox'
165162
aria-expanded='false'
166-
/>
163+
>
164+
<span className='slds-truncate'>{selected.label}</span>
165+
</button>
167166
<Button
168167
type='icon'
169168
icon='close'

src/scripts/Picklist.tsx

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ export type PicklistProps<MultiSelect extends boolean | undefined> = {
209209
tooltip?: ReactNode;
210210
tooltipIcon?: string;
211211
elementRef?: Ref<HTMLDivElement>;
212-
inputRef?: Ref<HTMLInputElement>;
212+
buttonRef?: Ref<HTMLButtonElement>;
213213
dropdownRef?: Ref<HTMLDivElement>;
214214
onValueChange?: Bivariant<
215215
(
@@ -251,7 +251,7 @@ export const Picklist: (<MultiSelect extends boolean | undefined>(
251251
tooltip,
252252
tooltipIcon,
253253
elementRef: elementRef_,
254-
inputRef: inputRef_,
254+
buttonRef: buttonRef_,
255255
dropdownRef: dropdownRef_,
256256
onSelect,
257257
onComplete,
@@ -373,8 +373,8 @@ export const Picklist: (<MultiSelect extends boolean | undefined>(
373373

374374
const elRef = useRef<HTMLDivElement | null>(null);
375375
const elementRef = useMergeRefs([elRef, elementRef_]);
376-
const comboboxElRef = useRef<HTMLInputElement | null>(null);
377-
const inputRef = useMergeRefs([comboboxElRef, inputRef_]);
376+
const comboboxElRef = useRef<HTMLButtonElement | null>(null);
377+
const buttonRef = useMergeRefs([comboboxElRef, buttonRef_]);
378378
const dropdownElRef = useRef<HTMLDivElement | null>(null);
379379
const dropdownRef = useMergeRefs([dropdownElRef, dropdownRef_]);
380380

@@ -607,9 +607,9 @@ export const Picklist: (<MultiSelect extends boolean | undefined>(
607607
className='slds-combobox__form-element slds-input-has-icon slds-input-has-icon_right'
608608
role='none'
609609
>
610-
<input
611-
type='text'
612-
ref={inputRef}
610+
<button
611+
type='button'
612+
ref={buttonRef}
613613
role='combobox'
614614
tabIndex={disabled ? -1 : 0}
615615
className={inputClassNames}
@@ -624,10 +624,9 @@ export const Picklist: (<MultiSelect extends boolean | undefined>(
624624
onKeyDown={onKeyDown}
625625
onBlur={onBlur}
626626
{...rprops}
627-
value={selectedItemLabel}
628-
readOnly
629-
disabled={disabled}
630-
/>
627+
>
628+
<span className='slds-truncate'>{selectedItemLabel}</span>
629+
</button>
631630
<Icon
632631
containerClassName='slds-input__icon slds-input__icon_right'
633632
category='utility'

0 commit comments

Comments
 (0)