Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dropdown: multiple defaultValue & value have incorrect types #4017

Closed
zhongeric opened this issue Aug 3, 2020 · 6 comments · Fixed by #4018
Closed

Dropdown: multiple defaultValue & value have incorrect types #4017

zhongeric opened this issue Aug 3, 2020 · 6 comments · Fixed by #4018

Comments

@zhongeric
Copy link
Contributor

Bug Report

Just stumbled across this - not sure if it's a bug or an user error.

Steps

A clear and concise description of steps to reproduce the problem.

Reproduce:

<Dropdown placeholder="Add tags" fluid multiple selection options={this.state.allTagsFormatted} onChange={this.handleTagChange} defaultValue={['VALUE1', 'VALUE2']} />

Where this.state.allTagsFormatted is an array of type key: string; text: string; value: string; created_date: string;

And passing an array of strings of options values into the defaultValue prop. Example: ['1111','2222', ...]

Expected Result

The result that you expected.

Compiles and pass type check per the docs:
`

defaultValue   {number|string|bool|arrayOf} Initial value or value array if multiple.

`

Actual Result

The actual result that happened 💣

Throws this typescript error:
Type 'string' is not assignable to type 'boolean'

Version

semantic-ui-react : "^1.1.0",
"typescript": "^3.9.7"
"@craco/craco": "^5.6.4",
"@semantic-ui-react/craco-less": "^1.2.1",
"semantic-ui-less": "^2.4.1"

Testcase

@welcome
Copy link

welcome bot commented Aug 3, 2020

👋 Thanks for opening your first issue here! If you're reporting a 🐞 bug, please make sure you've completed all the fields in the issue template so we can best help.

We get a lot of issues on this repo, so please be patient and we will get back to you as soon as we can.

@triage-new-issues triage-new-issues bot removed the triage label Aug 3, 2020
@layershifter layershifter changed the title Dropdown multiple default value incorrect type Dropdown: multiple defaultValue & value have incorrect type Aug 3, 2020
@layershifter layershifter changed the title Dropdown: multiple defaultValue & value have incorrect type Dropdown: multiple defaultValue & value have incorrect types Aug 3, 2020
@layershifter
Copy link
Member

Thanks for reporting 👍 It's the same as #4013 i.e. typings issue 😿


src/modules/Dropdown/Dropdown.d.ts

  /** Initial value or value array if multiple. */
-  defaultValue?: string | number | boolean | number | string | boolean[]
+  defaultValue?: string | number | boolean | (number | string | boolean)[]
  /** Current value or value array if multiple. Creates a controlled component. */
-  value?: boolean | number | string | boolean | number | string[]
+  value?: boolean | number | string | (boolean | number | string)[]

Would you like to a submit a PR to fix the issue? 😺

@zhongeric
Copy link
Contributor Author

#4018 @layershifter

Just submitted one, can't get past the label checks though haha

@xumix
Copy link

xumix commented Aug 12, 2020

@layershifter Hi! Any news on this? I'd really like to update to newer version of the lib.

@layershifter
Copy link
Member

@xumix released in 1.2.0, please check 🙏

@xumix
Copy link

xumix commented Aug 31, 2020

@xumix released in 1.2.0, please check 🙏

Thanks a lot!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants