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

fix(Select): expose generic types to allow by to work #2008

Merged
merged 2 commits into from
Jul 9, 2024

Conversation

booc0mtaco
Copy link
Contributor

  • borrow type value determination from HeadlessUI internals
  • add test to make sure types used map to params

Test Plan:

  • Wrote automated tests
  • CI tests / new tests are not applicable
  • Manually tested my changes, but I want to keep the details secret
  • Created and used an alpha publish
  • Manually tested my changes, and here are the details:

Copy link

codecov bot commented Jul 5, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 97.58%. Comparing base (661130b) to head (f3c7ae8).

Additional details and impacted files
@@           Coverage Diff           @@
##             next    #2008   +/-   ##
=======================================
  Coverage   97.58%   97.58%           
=======================================
  Files         109      109           
  Lines        2572     2572           
  Branches      645      645           
=======================================
  Hits         2510     2510           
  Misses         60       60           
  Partials        2        2           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link

github-actions bot commented Jul 5, 2024

size-limit report 📦

Path Size
components 88.47 KB (0%)
styles 27.65 KB (0%)

@booc0mtaco
Copy link
Contributor Author

I need to do some validation checks on this to make sure keyof is doing the right thing for the use cases we will support. right now, this should allow strings, or associative arrays for the values in a Select, and by should either be the allowed type of any of those keys, OR the comparison function which takes the full instance (whether it is a string OR an object)

Comment on lines +32 to +33
string | { [k: string]: unknown },
{ [k: string]: unknown }
Copy link
Contributor Author

Choose a reason for hiding this comment

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

the first line represents what is allowed in things like defaultValue or value

the second line represents what gets used when by is evaluated

  • when a simple string, by is string
  • when an object, by is the type of the keys on that object (usually string | number), or that eval function
  • ...

@booc0mtaco booc0mtaco force-pushed the aholloway/EDS-1356 branch from 9a96f9a to 4a0343f Compare July 8, 2024 16:08
- borrow type value determination from HeadlessUI internals
- add test to make sure types used map to params
@booc0mtaco booc0mtaco force-pushed the aholloway/EDS-1356 branch from 4a0343f to baf76da Compare July 8, 2024 16:47
@booc0mtaco booc0mtaco marked this pull request as ready for review July 8, 2024 19:05
@booc0mtaco booc0mtaco requested review from a team and forgeabout July 8, 2024 19:06
Copy link

@forgeabout forgeabout left a comment

Choose a reason for hiding this comment

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

LGTM. Thanks @booc0mtaco!

*/
export const WithSelectedBy: StoryObj<typeof Select> = {
args: {
...WithSelectedOption.args,

Choose a reason for hiding this comment

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

[non-blocking] It might be a more thorough test to use defaultValue: {...exampleOptions[1]} instead of inheriting defaultValue: exampleOptions[1] from WithSelectedOption since the purpose of by is to handle cases where the values are copies rather than the exact same objects.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

++ good call. I suspect it will work properly, but this will prevent some by-ref getting thru down the road

@booc0mtaco booc0mtaco merged commit 421c91b into next Jul 9, 2024
10 checks passed
@booc0mtaco booc0mtaco deleted the aholloway/EDS-1356 branch July 9, 2024 16:04
This was referenced Jul 12, 2024
booc0mtaco added a commit that referenced this pull request Jul 15, 2024
## [15.1.0](v15.0.1...v15.1.0) (2024-07-15)

[Storybook](https://61313967cde49b003ae2a860-qztphlqyid.chromatic.com/)

### Features

* add runtime warning/errors to components ([#2007](#2007)) ([661130b](661130b))
* **InputField:** add show/hide button for password field type ([#2006](#2006)) ([52d9ca0](52d9ca0))
* **Modal:** add height property to modal API ([#2011](#2011)) ([8d0c68f](8d0c68f))


### Bug Fixes

* **Icon:** update pencil icon to latest design ([#2016](#2016)) ([cb8d1a7](cb8d1a7))
* **Link:** apply font weight to standalone sizes ([#2015](#2015)) ([2e47271](2e47271))
* **Select:** expose generic types to allow by to pass type checks ([#2008](#2008)) ([421c91b](421c91b))
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.

2 participants