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

fix: Type error: (n.selected || []).slice is not a function in multiple select #1714

Merged
merged 2 commits into from
Feb 27, 2024

Conversation

johanrd
Copy link
Contributor

@johanrd johanrd commented Feb 27, 2024

I had an issue popping up in sentry, Type error: (n.selected || []).slice is not a function here:

defaultBuildSelection(option: any, select: Select) {
    const newSelection = (select.selected || []).slice(0);

The proposed fix checks for Array.isArray(select.selected) in runtime (which should not hurt), but we should probably also fix this by narrowing the type of Select.selected – possibly as a generic of what you pass in to options.

I had an issue popping up in sentry, `Type error: (n.selected || []).slice is not a function` on  

```ts
defaultBuildSelection(option: any, select: Select) {
    const newSelection = (select.selected || []).slice(0);
````

This fix checks for Array.isArray(select.selected) in runtime ( which should not hurt), but e should probably also fix this by narrowing the type of Select.selected – possibly as a generic of what you pass in to options.
@mkszepp mkszepp changed the title fix: Type error: (n.selected || []).slice is not a function fix: Type error: (n.selected || []).slice is not a function in multiple select Feb 27, 2024
@mkszepp mkszepp added the bug label Feb 27, 2024
@mkszepp mkszepp merged commit 7944962 into cibernox:master Feb 27, 2024
19 checks passed
@mkszepp
Copy link
Collaborator

mkszepp commented Feb 27, 2024

Thank you!

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

Successfully merging this pull request may close these issues.

None yet

2 participants