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

SegmentedControl does not work with an empty array #2400

Closed
hckhanh opened this issue Sep 9, 2022 · 2 comments
Closed

SegmentedControl does not work with an empty array #2400

hckhanh opened this issue Sep 9, 2022 · 2 comments
Labels
Fixed patch Completed issues that will be published with next patch (1.0.X)

Comments

@hckhanh
Copy link
Contributor

hckhanh commented Sep 9, 2022

What package has an issue

@mantine/core

Describe the bug

When I use segment with an initial empty array, I get this bug:

<SegmentedControl data={[]} value={'any value'} />
SegmentedControl.tsx:99 Uncaught TypeError: Cannot read properties of undefined (reading 'value')
    at SegmentedControl.tsx:99:140
    at renderWithHooks (react-dom.development.js:16305:18)
    at updateForwardRef (react-dom.development.js:19226:20)
    at beginWork (react-dom.development.js:21636:16)
    at HTMLUnknownElement.callCallback2 (react-dom.development.js:4164:14)
    at HTMLUnknownElement.__trace__ (inline-script-content.js:146:30)
    at Object.invokeGuardedCallbackDev (react-dom.development.js:4213:16)
    at invokeGuardedCallback (react-dom.development.js:4277:31)
    at beginWork$1 (react-dom.development.js:27451:7)
    at performUnitOfWork (react-dom.development.js:26557:12)

What version of @mantine/hooks page do you have in package.json?

5.2.5

If possible, please include a link to a codesandbox with the reproduced problem

No response

Do you know how to fix the issue

No

Are you willing to participate in fixing this issue and create a pull request with the fix

No response

Possible fix

I think it should allow the empty input data.

@hckhanh
Copy link
Contributor Author

hckhanh commented Sep 9, 2022

Another bug!
If i use empty string '' as a value, it does not work at all

import { SegmentedControl } from '@mantine/core';

function Demo() {
  return (
    <SegmentedControl
      data={[
        { label: 'All', value: '' },
        { label: 'React', value: 'react' },
        { label: 'Angular', value: 'ng' },
        { label: 'Vue', value: 'vue' },
        { label: 'Svelte', value: 'svelte' },
      ]}
    />
  );
}

@rtivital rtivital added Fixed patch Completed issues that will be published with next patch (1.0.X) and removed review required labels Sep 9, 2022
@rtivital
Copy link
Member

Fixed in 5.3.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Fixed patch Completed issues that will be published with next patch (1.0.X)
Projects
None yet
Development

No branches or pull requests

2 participants