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

[Bug]: NavDrawer: Cannot change the value if the initial value is undefined. #32875

Closed
2 tasks done
kkamik opened this issue Sep 20, 2024 · 1 comment
Closed
2 tasks done

Comments

@kkamik
Copy link

kkamik commented Sep 20, 2024

Library

React Components / v9 (@fluentui/react-components)

System Info

https://stackblitz.com/edit/f2xpac?file=src%2Fexample.tsx

Are you reporting an Accessibility issue?

None

Reproduction

https://stackblitz.com/edit/f2xpac?file=src%2Fexample.tsx

Bug Description

screen-capture.1.webm

Actual Behavior

Cannot change "selectedValue" and "selectedCategoryValue" if the initial value is undefined.

Expected Behavior

Can change "selectedValue" and "selectedCategoryValue" if the initial value is undefined.

Logs

No response

Requested priority

Blocking

Products/sites affected

No response

Are you willing to submit a PR to fix?

yes

Validations

  • Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
  • The provided reproduction is a minimal reproducible example of the bug.
@mainframev
Copy link
Contributor

mainframev commented Sep 20, 2024

hi @kkamik 👋🏻

It happens because you are changing the value from undefined to defined, the component has a check for controlled/uncontrolled behaviour. If you will open the console you will see the warning:

@fluentui/react-utilities [useControllableState]: A component is changing an uncontrolled value to be controlled. This is likely caused by the value changing from undefined to a defined value, which should not happen. Decide between using a controlled or uncontrolled input element for the lifetime of the component.

So in your case, you will have to set the default state value to some category, value different from undefined will work

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

No branches or pull requests

2 participants