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

bugfix/inputchips-updates-twice #1768

Merged

Conversation

Mahmoud-zino
Copy link
Sponsor Contributor

Linked Issue

Closes #1759

Description

after deleting

$: chipValues =
		value?.map((val, i) => {
			if (chipValues[i]?.val === val) return chipValues[i];
			return { id: Math.random(), val: val };
		}) || [];

every thing works as expected and the value is updated only once.

I have tested it with all use cases from the docs.

Changsets

bugfix: InputChips updates bound value only once.

Checklist

Please read and apply all contribution requirements.

  • This PR targets the dev branch (NEVER master)
  • Documentation reflects all relevant changes
  • Branch is prefixed with: docs/, feat/, chore/, bugfix/
  • Ensure Svelte and Typescript linting is current - run pnpm check
  • Ensure Prettier linting is current - run pnpm format
  • All test cases are passing - run pnpm test
  • Includes a changeset (if relevant; see above)

@changeset-bot
Copy link

changeset-bot bot commented Jul 18, 2023

🦋 Changeset detected

Latest commit: fb583a2

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

This PR includes changesets to release 1 package
Name Type
@skeletonlabs/skeleton 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

@vercel
Copy link

vercel bot commented Jul 18, 2023

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

Name Status Preview Updated (UTC)
skeleton-docs ✅ Ready (Inspect) Visit Preview Jul 18, 2023 6:32pm

@endigo9740
Copy link
Contributor

@Mahmoud-zino checking the Git Blame I see @Sarenor introduced this portion of the code per:

It looks like this was added to allow for null values to be handled by the autocomplete. Can the two of you sync on this and determine the best course of action here? My gut is telling me that just flat out removing this would introduce a regression.

@endigo9740 endigo9740 requested a review from Sarenor July 19, 2023 16:57
@endigo9740 endigo9740 marked this pull request as draft July 19, 2023 16:57
@Sarenor
Copy link
Contributor

Sarenor commented Jul 20, 2023

I just added the null-check, the initial code was added to handle duplicate values:
2ba426b
(by Chris, at that ;) ) which seems to work though, so the ID-Mapping is no longer necessary? Seems kind of strange but I'll take it!

Passing in an undefined list breaks the component though, and I'm not quite sure if we want that as intentional behaviour?

@endigo9740
Copy link
Contributor

Hmm, I wonder why the blame showed you. That's odd.

@Sarenor
Copy link
Contributor

Sarenor commented Jul 21, 2023

Cause it was me that changed those lines the last time when I added the || []; and prettier reformatted the lines :)

@Mahmoud-zino
Copy link
Sponsor Contributor Author

I will get back to this issue once I am done with the tree-view, I want to handle undefined without a reactive assignment, once this is done I think we can safely delete the reactive assignment.

@Mahmoud-zino
Copy link
Sponsor Contributor Author

@Sarenor

Passing in an undefined list breaks the component though, and I'm not quite sure if we want that as intentional behaviour?

can you please provide your setup, I tried passing undefined and got no errors, It is working as expected, maybe I am missing something here...

@endigo9740
Copy link
Contributor

@Sarenor just pinging you to remind you about @Mahmoud-zino request above.

@Sarenor
Copy link
Contributor

Sarenor commented Aug 9, 2023

@Mahmoud-zino Sorry, totally missed this while I was camping.
Got the reproduction here:
https://github.com/skeletonlabs/skeleton/compare/dev...Sarenor:skeleton:undefined-input-chip?expand=1
If I set the anything-list in the docs to undefined the docs page for InputChip doesn't load anymore

@Mahmoud-zino
Copy link
Sponsor Contributor Author

@Sarenor this happens because we are accessing the lists to display what is selected/allowed/not-allowed etc... on the docs page. but the error is not coming from the component.

so commenting this:

<code class="code">{anythingList.length ? anythingList.join(', ') : 'No chips available.'}</code>

the component will work as expected.
If you can confirm, I will mark the PR as ready for review

@Sarenor
Copy link
Contributor

Sarenor commented Aug 9, 2023

@Mahmoud-zino you are indeed correct and I'm a fool!

@Mahmoud-zino
Copy link
Sponsor Contributor Author

@Sarenor no no, it is just easy to miss 👍

@Mahmoud-zino Mahmoud-zino marked this pull request as ready for review August 9, 2023 14:35
@endigo9740
Copy link
Contributor

Thanks for your cooperation @Mahmoud-zino @Sarenor

I think with that we're good to move forward with this. I'll merge and we'll monitor the reaction from end users going forward.

@endigo9740 endigo9740 merged commit bc9e3e8 into skeletonlabs:dev Aug 9, 2023
3 checks passed
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.

InputChips subscribe twice to passed in store
3 participants