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

[Feature Request] [VTextField] Provide a focus() type #17299

Closed
0x00A1FA opened this issue May 5, 2023 · 1 comment
Closed

[Feature Request] [VTextField] Provide a focus() type #17299

0x00A1FA opened this issue May 5, 2023 · 1 comment
Assignees
Labels
T: bug Functionality that does not work as intended/expected typescript
Milestone

Comments

@0x00A1FA
Copy link

0x00A1FA commented May 5, 2023

Problem to solve

If I make a ref as such:

const searchFieldRef = ref<App.Helpers.Components.Instance<'VTextField'>>()

I don't get any type hints for focus. In fact, I get an error:

searchFieldRef.value?.focus()
/**
Property 'focus' does not exist on type '{ $: ComponentInternalInstance; $data: {}; $props: Partial<{ flat: boolean; reverse: boolean; type: string; error: boolean; active: boolean; direction: "horizontal" | "vertical"; ... 19 more ...; persistentCounter: boolean; }> & Omit<...>; ... 10 more ...; $watch<T extends string | ((...args: any) => any)>(source: T...'. Did you mean 'focused'?ts(2551)
index.d.ts(51767, 9): 'focused' is declared here.
*/

Proposed solution

Add the focus prop for VTextField (obviously extrapolate and make it so that all the Vuetify components that extend HTML elements also have those specific elements' props in their types lol).

@KaelWD KaelWD added T: bug Functionality that does not work as intended/expected typescript and removed S: triage labels May 5, 2023
@KaelWD KaelWD self-assigned this May 5, 2023
@KaelWD KaelWD added this to the v3.2.x milestone May 5, 2023
@KaelWD
Copy link
Member

KaelWD commented May 5, 2023

What the hell is App.Helpers.Components.Instance

all the Vuetify components that extend HTML elements also have those specific elements' props in their types

All the basic ones like VBtn are just ref.value.$el, text fields are special because the input element isn't the root.

@KaelWD KaelWD closed this as completed in 6fd1a13 May 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
T: bug Functionality that does not work as intended/expected typescript
Projects
None yet
Development

No branches or pull requests

2 participants