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

Textfield: Typings for on:change and on:input handlers #674

Open
throni3git opened this issue Dec 4, 2024 · 1 comment
Open

Textfield: Typings for on:change and on:input handlers #674

throni3git opened this issue Dec 4, 2024 · 1 comment
Labels
enhancement New feature or request

Comments

@throni3git
Copy link

throni3git commented Dec 4, 2024

Is your feature request related to a problem? Please describe.
I'd like to know what to use as type for the on:input and on:change callbacks in a number Textfield.

Describe the solution you'd like
A clear documentation in the Textfield demo components would be good.

Describe alternatives you've considered
What i already tried is CustomEvent<any> as well as a self defined type

export type EventWithTarget = Event & {
  target: EventTarget & HTMLInputElement;
};

but this was put together from something i read on Stackoverflow and i wonder if there is something official?

CustomEvent<any> does have target: EventTarget | null so i would have to check for target to be non-nullsy. And even then i get the hint Property 'value' does not exist on type 'EventTarget'. This seems a bit cumbersome to me.

Additional context
I am still using SMUI@7 and Svelte@4, but the question is more universal i think.

@throni3git throni3git added the enhancement New feature or request label Dec 4, 2024
@hperrin
Copy link
Owner

hperrin commented Dec 10, 2024

You'll have to use a ’CustomEvent & InputEvent’ workaround. SMUI 8 with Svelte 5 doesn't need it anymore, but older versions do. There's a demo on the website somewhere. I can't remember where. But also the website is updated for v8, so it would only be available on the v7 branch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants