@@ -9,6 +9,7 @@ import { makeVFieldProps } from '@/components/VField/VField'
9
9
import { makeVInputProps , VInput } from '@/components/VInput/VInput'
10
10
11
11
// Composables
12
+ import { useDisplay } from '@/composables'
12
13
import { makeAutocompleteProps , useAutocomplete } from '@/composables/autocomplete'
13
14
import { useAutofocus } from '@/composables/autofocus'
14
15
import { useFocus } from '@/composables/focus'
@@ -101,6 +102,8 @@ export const VTextarea = genericComponent<VTextareaSlots>()({
101
102
const vFieldRef = ref < VInput > ( )
102
103
const controlHeight = shallowRef ( '' )
103
104
const textareaRef = ref < HTMLInputElement > ( )
105
+ const scrollbarWidth = ref ( 0 )
106
+ const { platform } = useDisplay ( )
104
107
const autocomplete = useAutocomplete ( props )
105
108
const isActive = computed ( ( ) => (
106
109
props . persistentPlaceholder ||
@@ -157,6 +160,16 @@ export const VTextarea = genericComponent<VTextareaSlots>()({
157
160
if ( ! props . autoGrow ) rows . value = Number ( props . rows )
158
161
} )
159
162
function calculateInputHeight ( ) {
163
+ nextTick ( ( ) => {
164
+ if ( ! textareaRef . value ) return
165
+ if ( platform . value . firefox ) {
166
+ scrollbarWidth . value = 12
167
+ return
168
+ }
169
+ const { offsetWidth, clientWidth } = textareaRef . value
170
+ scrollbarWidth . value = Math . max ( 0 , offsetWidth - clientWidth )
171
+ } )
172
+
160
173
if ( ! props . autoGrow ) return
161
174
162
175
nextTick ( ( ) => {
@@ -232,7 +245,12 @@ export const VTextarea = genericComponent<VTextareaSlots>()({
232
245
} ,
233
246
props . class ,
234
247
] }
235
- style = { props . style }
248
+ style = { [
249
+ {
250
+ '--v-textarea-scroll-bar-width' : convertToUnit ( scrollbarWidth . value ) ,
251
+ } ,
252
+ props . style ,
253
+ ] }
236
254
{ ...rootAttrs }
237
255
{ ...inputProps }
238
256
centerAffix = { rows . value === 1 && ! isPlainOrUnderlined . value }
0 commit comments