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

Boolean values in config are ignored in Admin UI if they are false #1110

Closed
jacobwod opened this issue Jun 16, 2022 · 0 comments
Closed

Boolean values in config are ignored in Admin UI if they are false #1110

jacobwod opened this issue Jun 16, 2022 · 0 comments
Assignees
Milestone

Comments

@jacobwod
Copy link
Member

Describe the bug
A clear and concise description of what the bug is.

To Reproduce
Steps to reproduce the behavior:

  1. Go to Admin UI -> LayerSwitcher config
  2. Set visibleAtStart to false. This saves visibleAtStart: false to your map config.
  3. Open up Client. LayerSwitcher won't show. So far so good.
  4. Go back to Admin UI. Reload map config. The checkbox is still toggled.

Why?
Because:

visibleAtStart: existingConfig.visibleAtStart || this.state.visibleAtStart,

grabs the false in the first step and then the || operator sees false which makes it to continue to the next variable, so it reads the value from existing state (where it is true).

This should've been:

visibleAtStart: existingConfig.visibleAtStart ?? this.state.visibleAtStart,
@jacobwod jacobwod added this to the 3.10 milestone Jun 16, 2022
@jacobwod jacobwod self-assigned this Jun 16, 2022
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

1 participant