diff --git a/types/react-select/index.d.ts b/types/react-select/index.d.ts index 837af1df07..ff29e1992f 100644 --- a/types/react-select/index.d.ts +++ b/types/react-select/index.d.ts @@ -41,7 +41,7 @@ declare namespace ReactSelectClass { type OnBlurHandler = React.FocusEventHandler; type OptionRendererHandler = (option: Option) => HandlerRendererResult; type ValueRendererHandler = (option: Option) => HandlerRendererResult; - type OnValueClickHandler = (value: string, event: React.MouseEvent) => void; + type OnValueClickHandler = (option: Option, event: React.MouseEvent) => void; type IsOptionUniqueHandler = (arg: { option: Option, options: Options, labelKey: string, valueKey: string }) => boolean; type IsValidNewOptionHandler = (arg: { label: string }) => boolean; type NewOptionCreatorHandler = (arg: { label: string, labelKey: string, valueKey: string }) => Option; @@ -427,7 +427,7 @@ declare namespace ReactSelectClass { /** * onClick handler for value labels: function (value, event) {} */ - onValueClick?: OnValueClickHandler; + onValueClick?: OnValueClickHandler; /** * pass the value to onChange as a simple value (legacy pre 1.0 mode), defaults to false diff --git a/types/react-select/react-select-tests.tsx b/types/react-select/react-select-tests.tsx index 7ac189f231..15527339b1 100644 --- a/types/react-select/react-select-tests.tsx +++ b/types/react-select/react-select-tests.tsx @@ -186,6 +186,43 @@ describe("Examples", () => { } }); + it("onValueClick", () => { + class Component extends React.Component { + private onValueClick: ReactSelect.OnValueClickHandler = (option) => { + const optionValue: number = option.value; + } + + render() { + const options = [ + { value: 3, label: "Option 3" }, + { value: 9, label: "Option 9" } + ]; + + return ; + } + } + }); + + it("Custom value onValueClick", () => { + class Component extends React.Component { + private onValueClick: ReactSelect.OnValueClickHandler = (option) => { + const optionValue: CustomValueType = option.value; + } + + render() { + return ; + } + } + }); + it("Custom value onChange", () => { class Component extends React.Component { private onSelectChange: ReactSelect.OnChangeSingleHandler = (option) => {