Prevent Typing in Vuetify's Combobox - A Guide to Disabling Input in the Vuetify Combobox

Is there a way to prevent users from typing inside the vuetify combobox?

Below is my current implementation of the combobox:

<v-combobox
:loading="isSurveyBeingPopulated"
class="static--inputs"
color="red"
box
:items="folders"
:rules="[rules.required]"
item-text="value"
dense
placeholder="Select Survey Folder"
item-value="key"
slot="input"
v-model="selectedSurveyFolder">
</v-combobox>

Answer №1

Dropdown Menu:

The dropdown menu component allows users to select options from a list of items, with the added functionality of being able to input custom values that are not pre-defined. Any new values entered by the user will be recorded as text strings.

If disabling the ability to type custom values is necessary, consider using a select menu instead: https://vuetifyjs.com/en/components/selects

Select menus are ideal for presenting users with a list of choices and collecting their selection.

Answer №2

To remove a new item that has been modified, simply delete it.

<v-combobox
    v-model="selected"
    :items="[...selected, ...items]"
    multiple
    @change="onChangeCombobox"
/>
onChangeCombobox(items) {
  this.selected = items.filter((item) => this.items.includes(item))
}

Answer №3

Having encountered a similar challenge, I required a combobox that would showcase pre-defined options along with custom ones, all while preventing manual input. To achieve this, I leveraged key events to alter its functionality as shown below:

    @keydown="$event.target.blur()"
    @keypress="$event.target.blur()"
    @keyup="$event.target.blur()"

Answer №4

I encountered a similar issue, but I resolved it by opting for v-select instead of v-combobox and everything is functioning correctly:

<v-select
  return-object
></v-select>

Answer №5

Achieving combobox filtering can be done by implementing the following code snippets:

<v-combobox
  v-model="selection"
  :items="items"
  :search-input.sync="input"
  :rules="intRule"
  chips
  clearable
  dense
  multiple
  small-chips
  item-text="title"
  autocomplete="off"
  return-object
>
</v-combobox>

Within your script's data section, include something like this:

data() {
  return {
    selection: [],
    input: null,
    items: [],
    valid: false,
    intRule: [
      function(v) {
        if (!v || v.length < 0) {
          return false
        } else if (v.length > 0) {
          for (let i = 0; i < v.length; i++) {
            if (/[^0-9]/g.test(v[i].id)) {
              v.splice(-1, 1)
              return false
            }
          }
          return false
        } else {
          return true
        }
      }
    ]
  }
}

Utilize the input variable to handle scenarios where there are no search results found.

I trust that this information proves beneficial.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Implementation issue with Hashids library in Vue.js causing functionality hiccups

I'm having trouble getting the library hashids to cooperate with vue.js The method I would like to use is: <template> <div class="container"> {{ hashids.encode('1') }} </div> </template> <script& ...

Struggles with vue, vite, and Ubuntu 20 glitches

I'm feeling puzzled. After successfully saving my code to GitHub from Windows, I tried to open the exact same code on Ubuntu, using the same versions of Vite and Vue. However, the app failed to compile and I encountered multiple errors while attempti ...

Execute the Webpack-Dev-Server during the .NET Core compilation process

For the past few days, I've been struggling to make my .NET CORE app run my Vue.js application on the webpack-dev-server during Debug mode. Visual Studio seems to complicate this simple task unnecessarily. My attempt to add a Post-Build event like th ...

The state of vuex does not reveal its length

Within the vuex state, there is a variable 'images' defined as an array. When I use console.log(state.images), it shows output in this format: [__ob__: Observer] 0: {…} 1: {…} 2: {…} 3: {…} 4: {…} length: 5 __ob__: Observer {value: Arr ...

When a fresh tile is loaded in Mapbox, an event is triggered

As I work with the Mapbox GL JS API to manipulate maps, I find myself wondering if there is an event that can inform me whenever a new tile HTTP request is made. My code snippet looks like this: map.on("dataloading", e => { if(e.dataType ...

Issues arise when attempting to include the src attribute within the template tag in a Vuejs and Laravel project

After starting a project with Vuejs and Laravel using Laravel Mix, I encountered an issue. When attempting to split my component into separate files and load them in the .vue file as follows: <template src="./comp.html"></template> &l ...

Experience Markdown's Single Input Update Feature

I have recently developed a Markdown editor using Vue, similar to the examples found on Vue's website. However, my query is more related to implementation rather than Vue itself. Therefore, I am open to suggestions that do not necessarily involve Vue. ...

The currentRoute variable appears to be displaying a route value that is inconsistent with the value being displayed

Having trouble retrieving the current route of a component with router.currentRoute displaying unexpected behavior. router.currentRoute shows the intended route /admin: RefImpl {__v_isShallow: true, dep: undefined, __v_isRef: true, _rawValue: {…}, _valu ...

Issues arise when attempting to load a vue module within a micro-frontend setup

Still fairly new to VUE, I'm excited to implement the best practices I've picked up from other frontend technologies, particularly the micro-frontend approach. While I have successfully been able to dynamically load my module, I've hit a roa ...

What steps should I take to set up my Nuxt frontend app so that it recognizes the baseUrl of the Strapi backend?

I have been following these two tutorials: Creating a Deliveroo clone with Nuxt, Apollo, and Strapi Building a blog using Nuxt, Strapi, and Apollo Despite multiple attempts to understand the process by reading Strapi's documentation, I am strugglin ...

Is there a way to connect to multiple values in vue.js when creating a unique multiselect checkbox group?

While I understand how to connect a Vue application to a select element with the multiple attribute, in this scenario, I am dealing with a set of checkboxes that can be toggled on or off. These checkboxes represent features of a residency available for res ...

VueJS does not support certain characters in its JavaScript replace function

In my current situation, I am utilizing the replace method in the following manner: <code v-html="'/<try>/'.replace(/(?:\r\n|\r|\n)/g, 'testing')"></code> As I work with a longer string t ...

Tips for efficiently navigating to Vue methods, computeds, and data in VS Code!

I've attempted to utilize the symbol explorer in VSCode (CTRL+P then typing @). It enables me to navigate to methods by jumping to data, but I'm unable to jump to regular properties such as "computed:" or "methods:"? It would come in handy when ...

Having Trouble Loading Vue Devtools in Vue Electron Builder

I'm encountering an issue with loading Vue Devtools in my Electron application integrated with Vue. This is my first time working with this combination, and I suspect there might be a dependency problem causing the Devtools not to load within the Elec ...

Error: The reference to Vue has not been declared

We are in the process of implementing Jest into our current project. I created a sample test code, but encountered the following error: ReferenceError: Vue is not defined 1 | import User from "../components/modal/ad/AdAdd"; > 2 ...

Utilizing Axios to make a GET request and showcasing the outcomes on HTML using Vue

Recently delving into Vue and Axios, I am in the process of fetching data from an API to display it within an HTML card. However, it appears that the data is being attempted to be displayed before being retrieved from the API, resulting in nothing renderin ...

Using Vue.js to submit a form in Laravel and redirecting with a flash message

I am facing an issue where I have two components named Index and Create, loaded from separate blade files. The challenge is passing a flash message as a prop between these components due to their file separation. How can I redirect after submitting a form ...

Troubleshooting issues with the sidebar navigation in Laravel project using Vue and AdminLTE

I successfully installed AminLte v3 via npm in my Laravel + vue project and everything is functioning properly. However, I am facing an issue when I attempt to click on the main menu item in the Side navbar that is labeled as <li class="nav-item has-tr ...

Encountered an error while trying to compile the demo using VUE CLI3.0

click here for image description view image details WARNING Development server initialization... 95% copy files CopyPlugin ERROR Compilation failed with 1 error at 12:29:34 error found in ./src/router.js Module parsing error: Unexpected token (17 ...

Vue Router hit a snag: the call stack size has been surpassed

I've been trying to check if my jwt token is expired or not in my route guard. Somehow, I'm stuck in an infinite loop and can't figure out why. Here's the snippet of my code: Route Guard const parseJwt = (token) => { const base6 ...