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

[SelectField] Fix options with object value due to non-unique {#each} keys #425

Merged
merged 1 commit into from
Jul 8, 2024

Conversation

techniq
Copy link
Owner

@techniq techniq commented Jul 8, 2024

No description provided.

Copy link

vercel bot commented Jul 8, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
svelte-ux ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 8, 2024 1:56pm

Copy link

changeset-bot bot commented Jul 8, 2024

🦋 Changeset detected

Latest commit: 5d76661

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
svelte-ux Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link

Deploying svelte-ux with  Cloudflare Pages  Cloudflare Pages

Latest commit: 5d76661
Status: ✅  Deploy successful!
Preview URL: https://d2abf72c.svelte-ux.pages.dev
Branch Preview URL: https://fix-selectfield-object-value.svelte-ux.pages.dev

View logs

@techniq
Copy link
Owner Author

techniq commented Jul 8, 2024

Replaces #401. cc: @myieye

Copy link
Contributor

@myieye myieye left a comment

Choose a reason for hiding this comment

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

@techniq sorry I didn't reply to your questions a few weeks back. I'm on parental leave now.

Your solution is a bit cleaner than mine. I'm fine with it. I think JSON.stringify is quite fast.

Though, personally I think I'd still choose mine. I'm using short lists of medium sized objects and long lists of small objects. But there's nothing preventing someone from using long lists of large objects and then this could add a bit of unnecessary lag.

@techniq
Copy link
Owner Author

techniq commented Jul 8, 2024

First, congrats on the parental leave, and you're doing it wrong if you're responding to Github PRs :). I hope baby and mommy are doing good.

I agree on the performance on large lists might be measurable, and we'll address that if needed. I was concerned there might be cases where labels are not unique, and while groups might be leveraged, there is no guarantee. You can also attach additional properties to a menu option so JSON.stringify(option) the full option increases the likelihood of uniqueness across options.

I've also exposed a getKey() prop in the past if you wanted more control, which might be a solution if JSON.stringify performance is an issue. Also, I like to expose full control in a default slot / children so the user is able to implement their own {#each} block with more control for transitions, etc (something I do in LayerChart a good bit).

Anyways, I'm going to ship this approach for now, but will keep an eye on performance regressions.

@techniq techniq merged commit e8703ed into main Jul 8, 2024
5 checks passed
@techniq techniq deleted the fix-selectfield-object-value branch July 8, 2024 19:52
@github-actions github-actions bot mentioned this pull request Jul 8, 2024
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