Skip to content

Commit

Permalink
* picker: fix display not work as expected.
Browse files Browse the repository at this point in the history
  • Loading branch information
catouse committed Mar 26, 2024
1 parent f47403c commit cf9ffb4
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
1 change: 1 addition & 0 deletions lib/picker/dev.ts
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ onPageUpdate(() => {
items,
search: false,
multiple: true,
placeholder: '请选择你的最爱',
display: '已选择 {count} 项',
});
console.log('> noSearchMultiPicker', noSearchMultiPicker);
Expand Down
2 changes: 1 addition & 1 deletion lib/picker/src/component/picker-multi-select.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export class PickerMultiSelect extends PickTrigger<PickerState, PickerSelectProp
const showSearch = open && search;
let view: ComponentChildren;
const noSelections = !showSearch && !selections.length;
if (display && (noSelections || placeholder === undefined)) {
if (display && (!noSelections || placeholder === undefined)) {
if (typeof display === 'function') {
view = display.call(this, valueList, selections);
} else if (typeof display === 'string') {
Expand Down
4 changes: 2 additions & 2 deletions lib/picker/src/component/picker-single-select.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,13 @@ export class PickerSingleSelect extends PickTrigger<PickerState, PickerSelectPro
protected _renderTrigger(props: PickerSelectProps) {
const {children, state: {selections = [], value, open}, placeholder, search, disabled, readonly, clearable, display} = props;

const [selection = {text: '', value: ''}] = selections;
const [selection] = selections;
const showSearch = open && search;
let view: ComponentChildren;
if (showSearch) {
view = this._renderSearch(props);
} else if (selection || (placeholder === undefined && display)) {
const {text = ''} = selection;
const {text} = selection || {text: '', value: ''};
if (typeof display === 'function') {
view = display.call(this, value, selections);
} else if (typeof display === 'string') {
Expand Down

0 comments on commit cf9ffb4

Please sign in to comment.