Focus goes away from Input field, when setting data #14700
Replies: 2 comments 1 reply
-
|
So far I have been through my code a million times. Removed any unnecessary code, tried to log everything that happened, but nothing came out of it. After more testing, I have noticed this only goes if fieldName is 'id'*, but if it's anything else it works just fine. This field is not used anywhere else in the code (with the exception of one place, where another field that is exactly like 'id' is also used) So far I haven't been able to figure out why it's behaving like it is, but I might have found a solution. On the Vue components I will replace id with description and have the rest API return a field called description filled with the id field in the database. It seems to work fine (in my initial testing), but I would still love to find the reason behind this behaviour *Yes, unfortunately we have a text-field called id (used for description) and yes I would love to exchange a few not-so-nice words with the developer who thought this would be a good name for description |
Beta Was this translation helpful? Give feedback.
-
|
If you have more that one element with one id you'll have problems |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I'm having a situation here in my code, that I can't seem to understand. Unfortunately I haven't been able to recreate the problem in codepen. Maybe it's due to me using a lot of components, but I don't know how to show that in codepen
This is using VueJs v3.2.41 and Quasar v2.10.0
I have a component called InputField that looks like this (removed unneeded code):
My component shows an input field, with a few different setups based on IsNumberField. Notice they both use DataField for the v-model
Of the interesting props are the following
Data for v-model comes from DataField. As seen above, this component has an data object and the name of the field it needs to show/edit. When the user edits the data in any way, this change is then changing the correct field in the data object. No matter if it's a number field or not, the same code is run
My problem is that when this isNumberField is false and I make any change in the text, the q-input looses focus. @blur is never called and the timeline doesn't say anything, but it's clear that focus has been lost. This happens on the line this.data[this.fieldName] = newValue;
Removing that line "solves" the problem, but would of course mean that data is not changed. When isNumberField is true, then everything works just fine. Weird that the same code behaves in different ways in those two situations
This has worked before, unfortunately I have no idea when it started misbehaving. I looked at the history for this component, but can't see any changes that even the slightest could do something like this. I'm not using any emits (well, normally I am, but to fix the problem, I removed all of them) and I'm also not using watch. There's also no other computed that keeps an eye on the object or that field as far as I can tell (there was one, but I removed that one also)
Anybody who has even the slightest idea on what could be wrong?
As I mentioned, I am using many components, but I can't see any that could cause this, but I guess there has to be something somewhere
Beta Was this translation helpful? Give feedback.
All reactions