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

Merged
merged 7 commits into from
Jan 15, 2025

Conversation

hahn-kev
Copy link
Contributor

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: c6076cc

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 c6076cc

@@ -366,7 +367,7 @@
{max}
{step}
{actions}
bind:inputEl
bind:inputEl={null, (el) => (inputEl = el ?? null)}
Copy link
Contributor 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
Contributor 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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed the lint issues. FYI maybe this is because I'm on windows, but when I ran format it modified 486 files, in addition to the TextField file. I only checked in that one. That might trip up others though, I think it might be a BOM issue, but it's hard to tell what the changes are.

Copy link
Contributor Author

@hahn-kev hahn-kev Jan 15, 2025

Choose a reason for hiding this comment

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

Alright there's now also an example (really like how that system was designed btw, really cool), here's a screenshot of it, I figured I should include a toggle between single and multi-line since that's what this PR was mainly for.
image

@techniq techniq merged commit b31779b into techniq:main Jan 15, 2025
1 of 2 checks passed
@techniq
Copy link
Owner

techniq commented Jan 15, 2025

I still see some lint issues, but I'll fix them after merging. Thanks for the PR!

@techniq
Copy link
Owner

techniq commented Jan 15, 2025

Actually the failure was due to a test setup (and unrelated to this PR)

techniq added a commit that referenced this pull request Jan 15, 2025
@techniq
Copy link
Owner

techniq commented Jan 15, 2025

Released as 0.77.1. Thanks again!

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