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

feat(combobox)!: prefer strings as option values #637

Merged
merged 2 commits into from Apr 2, 2024

Conversation

geotrev
Copy link
Contributor

@geotrev geotrev commented Apr 2, 2024

  • BREAKING CHANGE?

Description

container-combobox has allowed consumers to set option.value with an object for ergonomics. This has proven to create unintended mismatches to selected values, and so this PR removes that compatibility feature, instead preferring all values to be strings for the best comparison.

Checklist

  • 🌐 demo is up-to-date (npm start)
  • πŸ’‚β€β™‚οΈ includes new unit tests
  • ~~:wheelchair: tested for WCAG 2.1 AA compliance
  • πŸ“ tested in Chrome, Firefox, Safari, and Edge

@geotrev geotrev self-assigned this Apr 2, 2024
@coveralls
Copy link

coveralls commented Apr 2, 2024

Coverage Status

coverage: 95.992% (+0.03%) from 95.963%
when pulling 409e8e1 on george/combobox-option
into 360f505 on main.

@@ -31,7 +31,7 @@ ComboboxContainer.propTypes = {
hasMessage: PropTypes.bool,
options: PropTypes.arrayOf(PropTypes.any).isRequired,
inputValue: PropTypes.string,
selectionValue: PropTypes.oneOfType([PropTypes.string, PropTypes.arrayOf(PropTypes.string)]),
selectionValue: PropTypes.any,
Copy link
Contributor Author

@geotrev geotrev Apr 2, 2024

Choose a reason for hiding this comment

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

This didn't seem to hold up after the type change, and I didn't find a way to define an accurate statement here using prop-types (using mixes of PropTypes.oneOf and PropTypes.oneOfType). Open to ideas if this seems like an issue.

@@ -8,7 +8,7 @@
import { IUseFieldReturnValue } from '@zendeskgarden/container-field';
import { HTMLProps, ReactNode, RefObject } from 'react';

export type OptionValue = string | object;
export type OptionValue = string;
Copy link
Contributor Author

@geotrev geotrev Apr 2, 2024

Choose a reason for hiding this comment

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

I liked the idea of retaining this type definition for internal use in spotting where values are referenced in code.

Copy link
Member

@jzempel jzempel Apr 2, 2024

Choose a reason for hiding this comment

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

The problem is that this doesn't play nice with the generated docs. I would favor removing entirely so that the updated docs are very clear that the value is now string only.

Oops, I was looking at the wrong docs. Currently looks good, so I'm fine either way.

@geotrev geotrev marked this pull request as ready for review April 2, 2024 16:37
@geotrev geotrev requested a review from a team as a code owner April 2, 2024 16:37
@@ -8,7 +8,7 @@
import { IUseFieldReturnValue } from '@zendeskgarden/container-field';
import { HTMLProps, ReactNode, RefObject } from 'react';

export type OptionValue = string | object;
export type OptionValue = string;
Copy link
Member

@jzempel jzempel Apr 2, 2024

Choose a reason for hiding this comment

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

The problem is that this doesn't play nice with the generated docs. I would favor removing entirely so that the updated docs are very clear that the value is now string only.

Oops, I was looking at the wrong docs. Currently looks good, so I'm fine either way.

@geotrev geotrev changed the title feat(combobox): prefer strings as option values feat(combobox)!: prefer strings as option values Apr 2, 2024
@geotrev geotrev merged commit 2de1b9b into main Apr 2, 2024
4 checks passed
@geotrev geotrev deleted the george/combobox-option branch April 2, 2024 18:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants