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

add bind:inputEl to textarea in TextField #531

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

hahn-kev
Copy link

closes #357

I didn't test this as I just checked out this repo for this simple change, I'm assuming CI will catch any issues this causes (if any)

Copy link

stackblitz bot commented Jan 13, 2025

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

Copy link

changeset-bot bot commented Jan 13, 2025

⚠️ No Changeset found

Latest commit: 1375d1c

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

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

Copy link
Contributor

github-actions bot commented Jan 13, 2025

built with Refined Cloudflare Pages Action

⚡ Cloudflare Pages Deployment

Name Status Preview Last Commit
svelte-ux ✅ Ready (View Log) Visit Preview 1375d1c

@@ -366,7 +367,7 @@
{max}
{step}
{actions}
bind:inputEl
bind:inputEl={null, (el) => (inputEl = el ?? null)}
Copy link
Author

Choose a reason for hiding this comment

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

this is using function bindings as defined here. The problem was that svelte thought we wanted to provide the value from TextField to Input, and since inputEl now may be a TextArea it was not happy with that since there's missing properties. This ensures that data flow is only one way out of the Input and into the TextField variable. I would have put a comment in code but there's not a good way to do that here.

Copy link
Owner

Choose a reason for hiding this comment

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

Thanks @hahn-kev. As of right now Svelte UX supports Svelte 3-5 (and will be for 1.x, but will be Svelte 5 only). I plan to release Svelte UX 1.0 VERY soon (maybe later this week) and have a PR that has started the migration to Svelte 5, but there is a lot of regression testing and refinements that need done.

With that said, we won't be able to use Svelte 5 function bindings yet (the docs are running Svelte 5 so it succeeds).

Here's my rough plan for Svelte UX 2.x (and others). Once we start the next branch I would love to include this, and plan to have incremental releases.

Copy link
Author

Choose a reason for hiding this comment

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

Ahh ok, I didn't realize that was a svelte 5 feature. I've changed this to do the same thing but an object to act as a wrapper which lets us define a setter without a getter.

Copy link
Owner

Choose a reason for hiding this comment

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

Nice technique! Care to run pnpm format to fix the prettier lint issue and I'll merge / release.

Copy link
Owner

Choose a reason for hiding this comment

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

Also, could you add an example or a way to validate the change. I don't have any component tests at the moment, just some unit tests and a lot of examples for visual/manual validation

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.

TextField with multiline doesn't get inputEl set
2 participants