From 644cb5b1aa8332abd7e9dbf4915492305926d52c Mon Sep 17 00:00:00 2001 From: Avior Date: Wed, 28 Sep 2022 14:16:01 +0200 Subject: [PATCH] fix: choices not having choices on start Signed-off-by: Avior --- src/Input/Input.stories.tsx | 24 ++++++++++++++++++++++++ src/Input/index.tsx | 4 ++++ 2 files changed, 28 insertions(+) diff --git a/src/Input/Input.stories.tsx b/src/Input/Input.stories.tsx index 519790f..de24de6 100644 --- a/src/Input/Input.stories.tsx +++ b/src/Input/Input.stories.tsx @@ -52,6 +52,30 @@ tmp.args = {defaultValue : 'd', label: 'Label', helper: 'Helper', choices: [ export const AutoComplete = tmp +tmp = Input.bind({}) +tmp.args = {label: 'Label', helper: 'Helper', strictChoices: true, choices: [ + 'a', + 'a', + 'a', + 'a', + 'a', + 'a', + 'a', + 'a', + 'b', + {value: 'd', display: 'D'}, + {value: '4', display: 'Mai'}, + 'cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc' +], iconLeft: { + icon: X, + transformer: (v: string) => { + console.log("POUET :D") + return "" + } +}} + +export const Select = tmp + tmp = Input.bind({}) tmp.args = {block: true, type: 'textarea', defaultValue : 'd', label: 'Label', helper: 'Helper', choices: [ 'a', diff --git a/src/Input/index.tsx b/src/Input/index.tsx index 5a957f0..42629a0 100644 --- a/src/Input/index.tsx +++ b/src/Input/index.tsx @@ -108,6 +108,10 @@ export default class Input extends React.PureComponent { }) } } + + if (this.props.choices) { + this.setState({list: this.buildList()}) + } } public componentWillUnmount() {