Skip to content

Commit

Permalink
fix(VOtpInput): form data support (#17955)
Browse files Browse the repository at this point in the history
  • Loading branch information
johnleider committed Aug 8, 2023
1 parent 0b3c47f commit 75aeb85
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions packages/vuetify/src/labs/VOtpInput/VOtpInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { useProxiedModel } from '@/composables/proxiedModel'

// Utilities
import { computed, ref, watch } from 'vue'
import { focusChild, genericComponent, IN_BROWSER, only, propsFactory, useRender } from '@/util'
import { filterInputAttrs, focusChild, genericComponent, IN_BROWSER, only, propsFactory, useRender } from '@/util'

// Types
import type { PropType } from 'vue'
Expand Down Expand Up @@ -78,7 +78,7 @@ export const VOtpInput = genericComponent<VOtpInputSlots>()({
'update:modelValue': (val: string) => true,
},

setup (props, { emit, slots }) {
setup (props, { attrs, emit, slots }) {
const { dimensionStyles } = useDimension(props)
const { isFocused, focus, blur } = useFocus(props)
const model = useProxiedModel(
Expand Down Expand Up @@ -202,6 +202,8 @@ export const VOtpInput = genericComponent<VOtpInputSlots>()({
})

useRender(() => {
const [rootAttrs, inputAttrs] = filterInputAttrs(attrs)

return (
<div
class={[
Expand All @@ -214,6 +216,7 @@ export const VOtpInput = genericComponent<VOtpInputSlots>()({
style={[
props.style,
]}
{ ...rootAttrs }
>
<div
ref={ contentRef }
Expand Down Expand Up @@ -263,6 +266,13 @@ export const VOtpInput = genericComponent<VOtpInputSlots>()({
</>
))}

<input
class="v-otp-input-input"
type="hidden"
{ ...inputAttrs }
value={ model.value.join('') }
/>

<VOverlay
contained
content-class="v-otp-input__loader"
Expand Down

0 comments on commit 75aeb85

Please sign in to comment.