Skip to content

fix: prevent picking values in disabled fields and disabled/readonly forms - #23375

Merged
J-Sek merged 3 commits into
vuetifyjs:masterfrom
Xapollon430:fix/disabled-controlled-selection
Nov 9, 2026
Merged

J-Sek merged 3 commits into
vuetifyjs:masterfrom
Xapollon430:fix/disabled-controlled-selection

Conversation

@Xapollon430

@Xapollon430 Xapollon430 commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

Description

VSelect, VAutocomplete, and VCombobox can still change their value when disabled if the application keeps an already-open menu open through the menu model.

Open Fruit with Apple selected. Set disabled on the field or its parent VForm, then click Orange in the controlled menu. Before the fix, Orange is selected and an update is emitted. After the fix, Apple stays selected and no update is emitted.

Each selection handler checks the effective disabled state before changing the model. The app can still control whether the menu is open.

Before and after video

All six browser regressions fail before the fix and pass after it. The full VSelect, VAutocomplete, and VCombobox browser suites pass (197 tests).

Markup

Paste this into packages/vuetify/dev/Playground.vue. Use ?kind=auto or ?kind=combo to try the other fields.

<template>
  <v-app theme="dark">
    <v-container max-width="600">
      <v-form :readonly="disabled">
        <div class="d-flex flex-column ga-4">
          <code>form readonly: {{ disabled }}</code>

          <v-select
            v-model="model.select"
            :items="items"
            :menu="menu.select"
            label="VSelect"
            @update:menu="updateMenu('select', $event)"
          />
          <v-autocomplete
            v-model="model.autocomplete"
            :items="items"
            :menu="menu.autocomplete"
            label="VAutocomplete"
            @update:menu="updateMenu('autocomplete', $event)"
          />
          <v-combobox
            v-model="model.combobox"
            :items="items"
            :menu="menu.combobox"
            label="VCombobox"
            @update:menu="updateMenu('combobox', $event)"
          />
          <v-date-input
            v-model="model.date"
            :menu="menu.date"
            label="VDateInput"
            hide-actions
            @update:menu="updateMenu('date', $event)"
          />
          <v-time-input
            v-model="model.time"
            :menu="menu.time"
            :picker-props="{ scrollable : 'controls' }"
            label="VTimeInput"
            hide-actions
            @update:menu="updateMenu('time', $event)"
          />
          <v-color-input
            v-model="model.color"
            label="VColorInput"
            hide-actions
          />

          <code>{{ model }}</code>
        </div>
      </v-form>
    </v-container>
  </v-app>
</template>

<script setup>
  import { onBeforeUnmount, reactive, shallowRef } from 'vue'

  const items = ['Apple', 'Orange', 'Pear']
  const disabled = shallowRef(false)
  const model = reactive({
    select: 'Apple',
    autocomplete: 'Apple',
    combobox: 'Apple',
    date: null,
    time: null,
    color: null,
  })
  const menu = reactive({
    select: false,
    autocomplete: false,
    combobox: false,
    date: false,
    time: false,
  })

  // app keeps an open menu open while the form is disabled
  function updateMenu (key, value) {
    if (!disabled.value) menu[key] = value
  }

  const timer = setInterval(() => disabled.value = !disabled.value, 2000)
  onBeforeUnmount(() => clearInterval(timer))
</script>

@J-Sek J-Sek added T: bug Functionality that does not work as intended/expected C: VSelect C: VCombobox C: VAutocomplete labels Nov 9, 2026
@J-Sek J-Sek added this to the v4.3.x milestone Nov 9, 2026
@J-Sek
J-Sek force-pushed the fix/disabled-controlled-selection branch from 54ca5b7 to 861b1a0 Compare November 9, 2026 04:01
@J-Sek J-Sek changed the title fix: prevent selection in disabled fields with an open menu fix: prevent picking values in disabled fields and disabled/readonly forms Nov 9, 2026
@J-Sek
J-Sek merged commit 4360201 into vuetifyjs:master Nov 9, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants