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

[Svelte] <Input> on:input event is not being propagated #237

Open
howesteve opened this issue Jul 6, 2022 · 1 comment
Open

[Svelte] <Input> on:input event is not being propagated #237

howesteve opened this issue Jul 6, 2022 · 1 comment
Assignees
Labels
bug Something isn't working high priority Items we want to tackle first

Comments

@howesteve
Copy link

So as the title says. The component is "eating" the "on:input" events.

If I try to use this:

<Input
  on:input={(e) => {
	  // never called
	  console.log('on:input');
  }}
/>

... callback is never called and nothing is print. Tracking down the source, I can see this is caused by this line:

on:input={e => value = e.target.value}

... which is not propagating the event. I was hoping to implement a "validate-on-type" using <Input/>.

Is this a bug or desired behavior?

Thanks,
Howe

@roblevintennis roblevintennis added the bug Something isn't working label Jan 16, 2023
@roblevintennis roblevintennis self-assigned this Jan 16, 2023
@roblevintennis roblevintennis added the high priority Items we want to tackle first label Jan 16, 2023
edwinwong added a commit to edwinwong/agnosticui that referenced this issue Mar 25, 2023
@edwinwong
Copy link

Hi, I looked into this and think I've fixed it. It looks like lines 392-420 of Input.svelte used:
value={value}
on:input={e => value = e.target.value}
rather than
bind:value.

This because type is dynamic in:
type={inputType}
so two-way binding through bind:value can't be used. It looks like this manual two-way binding doesn't bubble the manually created on:input event.

My commit changes line 342:
$: inputType = type;
to a use directive:
function typeAction(node) { node.type = type; }
so that the type of the inputs can be assigned non-dynamically:
<input use:typeAction>
allowing for the use of bind:value.

The inputs now have a simple on:input event which appears to bubble properly.

I'm submitting a pull request, hope this is fix is correct!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working high priority Items we want to tackle first
Projects
None yet
Development

No branches or pull requests

3 participants