Skip to content

Conversation

@domharrington
Copy link
Member

🧰 Changes

  • Return with a value from the top level if it's not set in the keys[]
  • Return with a default if it's not set in the keys[]
  • Do not render a dropdown if the value hasn't come from the keys[]
  • Do not render a dropdown if there's only one value in the keys[]

🧬 QA & Testing

Do the tests pass? ✅
I've tested this npm linked into ReadMe but I wanna do a little more full QA to ensure all of these different edge cases are working as expected over there.

- Return with a value from the top level if it's not set in the keys[]
- Return with a default if it's not set in the keys[]
- Do not render a dropdown if the value hasn't come from the keys[]
- Do not render a dropdown if there's only one value in the keys[]
Copy link
Contributor

@gratcliff gratcliff left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's quite the change! Code looks solid to me.

shouldShowVarDropdown(selected) {
const { user, variable } = this.props;

return !!this.getSelectedValue(selected)[variable] && Array.isArray(user.keys) && user.keys.length > 1;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should it only count keys with values? Is that possible?

Suggested change
return !!this.getSelectedValue(selected)[variable] && Array.isArray(user.keys) && user.keys.length > 1;
return !!this.getSelectedValue(selected)[variable] && Array.isArray(user.keys) && user.keys.filter(key => key.name === variable).length > 1;

Copy link
Member Author

@domharrington domharrington Jun 29, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We're already checking if this particular variable has a value assigned in the first part of this statement:

!!this.getSelectedValue(selected)[variable]

Is that sufficient for the use case you're referring to? If there isn't a user.keys[variable] then it'll already have exited early from that statement because we already know not to show the var dropdown. So at that point, checking the length should suffice? Unless i'm misunderstanding.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gotcha gotcha, misread that.

@erunion
Copy link
Member

erunion commented Jun 29, 2022

lgtm, @domharrington want me to merge and tag a release for you?

@domharrington
Copy link
Member Author

@erunion yes please 🙏

@erunion erunion merged commit 711da56 into main Jun 29, 2022
@erunion erunion deleted the feature/better-value-selection branch June 29, 2022 20:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants