Skip to content

Commit 7eeabb2

Browse files
committed
chore: multi select never has empty item
1 parent 6cb0aad commit 7eeabb2

6 files changed

Lines changed: 16 additions & 30 deletions

File tree

packages/pluggableWidgets/datagrid-dropdown-filter-web/src/DatagridDropdownFilter.editorPreview.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ function Preview(props: DatagridDropdownFilterPreviewProps): ReactElement {
1414
options={[]}
1515
empty={!props.clearable}
1616
clearable={props.clearable}
17+
showCheckboxes={false}
1718
value={getPreviewValue(props)}
1819
onClear={noop}
1920
useSelectProps={() => ({ items: [] })}

packages/shared/widget-plugin-dropdown-filter/src/controllers/mixins/SelectControllerMixin.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ export function SelectControllerMixin<TBase extends BaseController>(Base: TBase)
4141
}
4242

4343
get options(): OptionWithState[] {
44+
if (this.multiselect) {
45+
return this.filterStore.options;
46+
}
4447
return [this.emptyOption, ...this.filterStore.options];
4548
}
4649

packages/shared/widget-plugin-dropdown-filter/src/controls/base/OptionsWrapper.tsx

Lines changed: 11 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,7 @@ type OptionsWrapperProps = {
1818
isOpen: boolean;
1919
options: OptionWithState[];
2020
highlightedIndex: number;
21-
showCheckboxes?: boolean;
22-
haveEmptyFirstOption?: boolean;
21+
showCheckboxes: boolean;
2322
} & (
2423
| Pick<UseComboboxPropGetters<OptionWithState>, "getMenuProps" | "getItemProps">
2524
| Pick<UseSelectPropGetters<OptionWithState>, "getMenuProps" | "getItemProps">
@@ -28,17 +27,7 @@ type OptionsWrapperProps = {
2827
const noop = (): void => {};
2928

3029
export const OptionsWrapper = forwardRef((props: OptionsWrapperProps, ref: RefObject<HTMLDivElement>): ReactElement => {
31-
const {
32-
cls,
33-
style,
34-
onMenuScroll,
35-
isOpen,
36-
highlightedIndex,
37-
showCheckboxes,
38-
haveEmptyFirstOption,
39-
getMenuProps,
40-
getItemProps
41-
} = props;
30+
const { cls, style, onMenuScroll, isOpen, highlightedIndex, showCheckboxes, getMenuProps, getItemProps } = props;
4231
return (
4332
<div className={cls.popover} hidden={!isOpen} ref={ref} style={style}>
4433
<div className={cls.menuSlot}>
@@ -54,19 +43,15 @@ export const OptionsWrapper = forwardRef((props: OptionsWrapperProps, ref: RefOb
5443
>
5544
{showCheckboxes && (
5645
<span className={cls.checkboxSlot}>
57-
{haveEmptyFirstOption && index === 0 ? (
58-
<div style={{ width: 16, height: 16 }} />
59-
) : (
60-
<input
61-
className={props.cls.checkbox}
62-
role="presentation"
63-
type="checkbox"
64-
checked={item.selected}
65-
value={item.caption}
66-
onChange={noop}
67-
tabIndex={-1}
68-
/>
69-
)}
46+
<input
47+
className={props.cls.checkbox}
48+
role="presentation"
49+
type="checkbox"
50+
checked={item.selected}
51+
value={item.caption}
52+
onChange={noop}
53+
tabIndex={-1}
54+
/>
7055
</span>
7156
)}
7257
{item.caption}

packages/shared/widget-plugin-dropdown-filter/src/controls/combobox/Combobox.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,6 @@ export const Combobox = observer(function Combobox(props: ComboboxProps) {
6969
options={props.options}
7070
highlightedIndex={highlightedIndex}
7171
showCheckboxes={false}
72-
haveEmptyFirstOption={false}
7372
getMenuProps={getMenuProps}
7473
getItemProps={getItemProps}
7574
/>

packages/shared/widget-plugin-dropdown-filter/src/controls/select/Select.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ interface SelectProps {
1414
clearable: boolean;
1515
empty: boolean;
1616
className?: string;
17-
showCheckboxes?: boolean;
17+
showCheckboxes: boolean;
1818
style?: React.CSSProperties;
1919
useSelectProps: () => UseSelectProps<OptionWithState>;
2020
onClear: () => void;
@@ -72,7 +72,6 @@ export const Select = observer(function Select(props: SelectProps): React.ReactE
7272
options={props.options}
7373
highlightedIndex={highlightedIndex}
7474
showCheckboxes={showCheckboxes}
75-
haveEmptyFirstOption
7675
getMenuProps={getMenuProps}
7776
getItemProps={getItemProps}
7877
/>

packages/shared/widget-plugin-dropdown-filter/src/controls/tag-picker/TagPicker.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,6 @@ export const TagPicker = observer(function TagPicker(props: TagPickerProps): Rea
123123
options={props.options}
124124
highlightedIndex={highlightedIndex}
125125
showCheckboxes={showCheckboxes}
126-
haveEmptyFirstOption={false}
127126
getMenuProps={getMenuProps}
128127
getItemProps={getItemProps}
129128
/>

0 commit comments

Comments
 (0)