Why would triggering an input event have any effect if it doesn't appear to be utilized anywhere?

We have developed a custom Vuetify 3 component known as FilterPanel. Here is a simplified version:

<template>
  <div>
    <v-container>
      <v-row>
        <v-col cols="3">
          <v-select v-model="field" :items="fields" :menu-props="{ auto: true }">
            <v-field />
          </v-select>
        </v-col>
        <v-col>
          <v-text-field v-model="text" :type="(formats && formats[field]) || 'text'" @keyup.enter="add" />
        </v-col>
        <v-col cols="2">
          <v-btn @click="add()">
            Add Filter
            <v-icon end theme="dark"> mdi-filter-plus </v-icon>
          </v-btn>
        </v-col>
      </v-row>
    </v-container>
    <v-chip>
      ... content removed for brevity
    </v-chip>
  </div>
</template>

The previous version, Vuetify 2, had a similar structure:

<template>
  <div>
    <v-text-field v-model="text" :type="(formats && formats[field]) || 'text'" @keyup.enter="add">
      <v-select slot="prepend-inner" v-model="field" :items="fields" menu-props="auto" />
      <v-btn slot="append" @click="add()" >
        Add Filter
        <v-icon right dark>mdi-filter-plus</v-icon>
      </v-btn>
    </v-text-field>
    <v-chip>
      ... content removed for brevity
    </v-chip>
  </div>
</template>

Further down the file (within the <scripts> section), there are several lines within different methods on the exported object:

this.$emit('input', { ...this.value, ...qFields })

this.$emit('input', { ...this.value, [this.field]: this.text })

this.$emit('input', omit(this.value, key))

In the transition from Vuetify 2 to Vuetify 3, it appears that this.value is now undefined, whereas previously it was equivalent to { [this.field]: this.text } in terms of functionality. The purpose and implementation of these emits are currently unclear to us.

We could potentially take one of the following actions:

  1. Delete the emits entirely
  2. Modify the emission to reconstruct this.value (e.g.
    this.$emit('input', { ...{ [this.field]: this.text }, ...qFields })
    )
  3. Adjust based on any changes introduced in Vuetify 3 that were not covered in the migration guide. One observation we made was:
    @input event has been replaced by @update:model-value on components that support v-model usage.
    However, the exact steps to address this change remain uncertain - should we modify the first emit parameter only, or also make alterations to the second parameter?

Your insights would be greatly appreciated!

Answer №1

It seems that the lack of @input events being triggered is due to the component's usage of v-model.

In Vue 2, v-model simplifies binding by using :value as a prop and listening for @input events. In Vue 3, this has been updated to utilize :modelValue as the prop and listen for @update:modelValue events. To resolve this issue, consider renaming your value to

modelValue</code and emitting <code>update:modelValue
instead of an input event.


Further insight suggests that this custom component facilitates property selection and value assignment within the this.value object. It may also support overriding properties with preset values or removing certain properties altogether.

When input data is provided for a selected field, it emits:

this.$emit('input', { ...this.value, [this.field]: this.text })

This action generates a new object based on the input from the prop :value, updating the specified this.field key with the corresponding this.text.

If multiple properties are overridden, it emits:

this.$emit('input', { ...this.value, ...qFields })

This process merges all existing properties from the prop :value with those in qFields, potentially replacing any matching keys.

To remove a property from

:value</code, it emits:</p>
<pre><code>this.$emit('input', omit(this.value, key))

Keep in mind that assumptions are made without insight into qFields, omit(), or key, along with how the component is implemented. Feel free to provide more context for clearer assistance.

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

Code for switching between accordion panels with a simple button press

I took some code snippets from a website and developed a shopping cart accordion module. The complete code is available on my CodePen profile, you can access it through this link: http://codepen.io/applecool/pen/YXaJLa <div class="summary"> <but ...

Is there a way to go about installing node_modules?

After running the npm i command to install node_modules in my vue.js project, I encountered the following error message: npm ERR! code E404 npm ERR! 404 Not Found - GET https://registry.npmjs.org/@fds%2flima-ticket-validator - Not found npm ERR ...

Is it possible to access the ID of a collection_select and have a list of items appear whenever the selection is modified?

I am working on a form named _form.html.erb <%= simple_form_for(@exam) do |f| %> <%= f.error_notification %> <div class="field"> <%= f.label :Year %> <%= f.collection_select :year_id, Year.order(:name), :id, :name, ...

Move and place multimedia items using IE's drag and drop feature

Is there a way to enable the drag and drop feature across different browsers or windows using HTML5's native DnD API? I have noticed that when I set the data type to 'text' in Internet Explorer, it functions properly. However, if I attempt t ...

Alter the reply prior to being dispatched to the customer

Node 16.14.2, Express 4.18.1 There have been several instances where individuals have altered res.send in order to execute actions before the response is sent to the client. app.use(function (req, res, next) { originalSend = res.send; res.send = f ...

Swapping out the entire vue.js container

I have a custom vue.js widget that I initialize like so: var myWidget = new Vue({ el: '#widget-container', methods: { loadData:function() { // custom functionality here } }, }); The HTML structure is as f ...

Following the parsing of the list of months, the sequence undergoes a

After receiving the JSON encoded object from the server side in PHP MONTHLY_FORMAT, I am reading that object in jQuery as: var MONTHLY_FORMAT = '<?php echo $MONTHLY_FORMAT; ?>'; When checking the console output, it looks like this: {"0 ...

Conceal any zero values from an empty numerical input

Currently, I have a form that retrieves data from a database and includes a number input type field. When the field is empty, it defaults to displaying "0." However, I would like to hide the "0" and only show the value if it is different from 0. Despite a ...

Leveraging API data within React: A step-by-step guide

I have a React application where I am making API calls. To manage these calls, I created a separate file called dataService.js to contain all the functions for interacting with the API. However, when trying to log the data in my component, I am getting a ...

Creating secure paths with ReactJS

I'm currently working on implementing protected routes in my React application. I have a Node.js backend with an endpoint called /isLoggedIn that checks if the user is logged in. The backend functionality is working fine, but I'm encountering mul ...

Executing a function with the initial click

Is there a way to run a function only on the first click, without having it run every time? I already have another function running on window.onload, so I can't use that. Both functions work fine independently, but not together. Right now, I'm ca ...

I am having trouble unzipping the file

I encountered an issue while attempting to download a .zip file from Discord and extracting it using the decompress package. Despite not returning any errors, the package did not get extracted as expected. (The file was saved and downloaded correctly) co ...

Transfer the updated variable from a static JavaScript file to Next.js

I am facing a challenge with a conditional render in my component. I am unable to display the value of a variable. In one file, I have all my functions that I export in index.js import FunctionServices from "../services/functionServices" export ...

Is there a way to mount or unmount a React component by pressing a single key?

I am currently developing an application that showcases 3D objects upon pressing certain keys on the keyboard. My goal is to have these objects disappear after 2-3 seconds or once the animation completes. Below is the component responsible for managing th ...

Exploring the Power of Two jQuery Ajax Functions in Your Script

Is it possible to provide guidance on how I can successfully execute two separate Ajax calls within a single script without encountering conflicts? A sample of the current script structure is as follows: <script type="text/javascript"> $(document).r ...

Tips for preserving drop down selections when refreshing the page

I am currently working on a program with 2 drop-down menus and 2 buttons. My goal is to have the first button disabled and second enabled when both dropdowns are selected and the "start" button is clicked. Additionally, I want the dropdowns to be disabled ...

Search through an array of objects and assign a new value

I am facing a challenge with an array of objects structured as shown below: [ { "e_id": "1", "total": 0 }, { "e_id": "3", "total": 0 } ] My objecti ...

Warning: The core schema has detected an unknown property `color` for the component or system `undefined` in Aframe + Vuejs. This issue was flagged within 10 milliseconds in

I am facing some challenges trying to integrate Aframe and vuejs seamlessly, as the console is displaying warning messages. It seems like Aframe is validating the attribute values before vue has a chance to modify them. Warning messages core:schema:warn ...

Issues with refreshing Laravel Vue components

After installing Laravel 5.4, I created a new component which displayed correctly. Running 'npm run watch' compiled my .vue files successfully. However, any changes made to the .vue files do not reflect the updates. Even after intentionally cr ...

having difficulties retrieving the attribute value through jquery

I'm currently implementing this method on rowmouseevent. When I use $get(eventArgs.get_id()), the output is: <tr class="normal" data-value="normal" id="ctl00_ContentPlaceHolder1_UserGrid_grdusergrid_ctl00__0" style="height:30px;" /tr> How can ...