Skip to content
This repository was archived by the owner on Jul 19, 2019. It is now read-only.

[changed] isOpen function treats null or undefined prop as not being set#285

Open
acunniffe wants to merge 2 commits intoreactjs:masterfrom
acunniffe:master
Open

[changed] isOpen function treats null or undefined prop as not being set#285
acunniffe wants to merge 2 commits intoreactjs:masterfrom
acunniffe:master

Conversation

@acunniffe
Copy link
Copy Markdown

Some users may want to use the isOpen override selectively depending on the app state. Right now even if you set it as undefined or null the code treats that as a definitive false.

Currently:
true is treated as true
false is treated as false
null is treated as false
undefined is treated as false

With this PR:
true is treated as true
false is treated as false
undefined is treated as [not set]
null is treated as [not set]

Aidan Cunniffe added 2 commits October 16, 2017 12:45
…set.

some users may want to override isOpen and use the default behavior and
logic. JSX does not support conditional setting of props so null is
often treated as not set at all.
@CMTegner
Copy link
Copy Markdown
Collaborator

Hi Aidan! I agree, this change is probably sensible. The original thought was that props.open would be either managed, or unmanaged, like how props.value works in React's implementation of <input>. That's also why we implemented props. onMenuVisibilityChange, so that you could mirror Autocomplete's open state when you didn't want to override it.

Sadly, changing this logic as proposed would probably break a few implementations. It's very easy to pass undefined/null instead of false by accident, and not everyone is good at ensuring there are no prop type violations. I'll hold off on this until v2.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants