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

fix(VFileInput): expose InputHTMLAttributes type #17077

Closed
wants to merge 4 commits into from
Closed

Conversation

yuwu9145
Copy link
Member

@yuwu9145 yuwu9145 commented Apr 4, 2023

fix #17069

It is supported in v2

InputHTMLAttributes including accept should be type supported in VFileInput.

input attributes like accept will be passed to input via attributes

Allows users to safely specify any legit input(file) attributes. e.g. autofocus, accept ...

Description

fix #17069

Markup:

<template>
  <v-app>
    <v-main>
      
      <v-file-input id="a" autofocus accept="image/png, image/jpeg"></v-file-input>
    </v-main>
  </v-app>
</template>

<script lang="ts">

</script>

@yuwu9145 yuwu9145 marked this pull request as draft April 4, 2023 05:54
@yuwu9145 yuwu9145 self-assigned this Apr 4, 2023
@yuwu9145 yuwu9145 changed the title fix(VFileInput): Add accept prop fix(VFileInput): support InputHTMLAttributes type Apr 4, 2023
@yuwu9145 yuwu9145 marked this pull request as ready for review April 4, 2023 06:18
@yuwu9145 yuwu9145 requested a review from johnleider April 4, 2023 06:18
@yuwu9145 yuwu9145 requested a review from KaelWD April 4, 2023 06:44
@yuwu9145 yuwu9145 changed the title fix(VFileInput): support InputHTMLAttributes type fix(VFileInput): expose InputHTMLAttributes type Apr 4, 2023
@KaelWD
Copy link
Member

KaelWD commented Apr 4, 2023

This shouldn't be necessary, we don't want to list every possible html attribute in the docs:

Screenshot_20230404_171642

Arbitrary attributes should be supported on every component:

https://discord.com/channels/340160225338195969/660898563139567625/1091801131128205423
Screenshot_20230404_171743
image

@KaelWD
Copy link
Member

KaelWD commented Apr 4, 2023

declare module '@vue/runtime-core' {
  export interface AllowedComponentProps {
    [key: string]: any;
  }
}

I don't think we should include this ourselves though

@yuwu9145
Copy link
Member Author

yuwu9145 commented Apr 4, 2023

This shouldn't be necessary, we don't want to list every possible html attribute in the docs:

InputHTMLAttributes should not be in our docs. However, they should be in the same category as "class" "style" whose types should be allowed by default. Current runtime behaviour is these attributes are being passed to input tag via { ...inputAttrs } (if you inspect VInput, you will see accept & autofocus are rendered into the dom), the problem is this isn't reflected in type check.

Arbitrary attributes should be supported on every component:

I agree with you, this should not be in our end. Having said this, allowing arbitrary attributes does not mean allowing arbitrary values , we will still need InputHTMLAttributes to guard attr values are in correct type:

image

@yuwu9145
Copy link
Member Author

yuwu9145 commented Apr 4, 2023

declare module '@vue/runtime-core' {
export interface AllowedComponentProps {
[key: string]: any;
}
}
I don't think we should include this ourselves though

vuejs/language-tools#1077 (comment)

@KaelWD I tested in my local , user can define arbitrary attributes types via AllowedComponentProps in their end. It is working in my local when I made a shim.d.ts file in packages/vuetify/dev/shim.d.ts

image

@websitevirtuoso
Copy link
Contributor

I have no idea why we need this but I can set any attr to any elements. I also use vite +TS and everything works. it doesn't make sense define each attr for TS. It can be added in docs or somewhere else I think

@johnleider
Copy link
Member

What updates are needed to this PR to make it viable @KaelWD @nekosaur ?

@KaelWD
Copy link
Member

KaelWD commented Apr 19, 2023

Closing in favour of #17082

@KaelWD KaelWD closed this Apr 19, 2023
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.

[Feature Request] [VFileInput] Types: Add accept attribute (Volar gives error now)
4 participants