Skip to content

Commit

Permalink
* picker: fix selected item text now show in control with remote items.
Browse files Browse the repository at this point in the history
  • Loading branch information
catouse committed May 23, 2024
1 parent e133cb6 commit 78bd532
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lib/picker/src/component/picker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,11 @@ export class Picker<S extends PickerState = PickerState, O extends PickerOptions
const newState = typeof state === 'function' ? state(prevState) : state;
if ((newState.value !== undefined && newState.value !== prevState.value) || (newState.items && newState.items !== prevState.items)) {
const items = newState.items || prevState.items;
const map = getValueMap(items);
const map: Map<string, PickerItemOptions> = new Map();
if (Array.isArray(prevState.items) && prevState.items !== newState.items) {
getValueMap(prevState.items as PickerItemOptions[], map);
}
getValueMap(items, map);
newState.selections = this.formatValueList(newState.value ?? prevState.value).reduce<PickerItemBasic[]>((list, value) => {
if (!this.isEmptyValue(value)) {
list.push(map.get(value) || {value, text: value});
Expand Down

0 comments on commit 78bd532

Please sign in to comment.