Skip to content

Commit

Permalink
fix(onchange bug): onchange bug (#231)
Browse files Browse the repository at this point in the history
affects: @gio-design/components, website
  • Loading branch information
zhaoting zhou authored Sep 23, 2020
1 parent e3b2fd4 commit 4fcfc9e
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
4 changes: 3 additions & 1 deletion packages/components/src/components/select/Select.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,9 @@ const Select: React.FC<SelectProps> = (props: SelectProps) => {
);
clearInput();
if (onChange) {
const selectedOptions = Array.from(selection).map((value) => extendedOptions[optionHash.get(value)]);
const selectedOptions = Array.from(optSelection).map(
(value) => extendedOptions[optionHash.get(value)] || freeInputOption(value)
);
onChange(multiple ? selectedOptions : selectedOptions[0]);
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ import '@gio-design/components/es/components/select/style/index.css';

import options from './options';

const Basics = (): React.ReactNode => <Select options={options} multiple width={200} />;
const Basics = (): React.ReactNode => <Select options={options} multiple width={200} onChange={console.log} />;

export default Basics;
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ const options = values.map((value, index) => ({

const Basics = (): React.ReactNode => (
<>
<Select options={options} searchable width={200} />
<Select options={options} searchable width={200} onChange={console.log} />
<br />
<Select options={options} multiple searchable width={200} />
<Select options={options} multiple searchable width={200} onChange={console.log} />
</>
);

Expand Down

0 comments on commit 4fcfc9e

Please sign in to comment.