Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Warning if v-model is empty or becomes empty #22

Open
arnauddsj opened this issue Aug 19, 2022 · 6 comments
Open

Warning if v-model is empty or becomes empty #22

arnauddsj opened this issue Aug 19, 2022 · 6 comments
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@arnauddsj
Copy link

Hello,

I'm getting this warning if I click on a contenteditable div and click outside without having typed anything.
[Vue warn]: Invalid event arguments: event validation failed for event "update:modelValue".

my v-model points to a ref("")
It also shows as soon as the v-model goes back to an empty string (when I erase the string for example)

Thank you for this plugin it's very convenient!

@hl037
Copy link
Owner

hl037 commented Aug 19, 2022

Hi,
That's weird, I may not have noticed it since sometimes I disable warnings in the dev tool, have look into it. Which version of vue and vue-contenteditable are you using ?

Thnank you for reporting anyway

@arnauddsj
Copy link
Author

"vue-contenteditable": "^4.0.4"

"vite": "^3.0.4"
"vue": "^3.2.37",
"@vueuse/core": "^9.1.0",

@ms2d
Copy link

ms2d commented Nov 6, 2022

I am getting the same warning. If I entirely delete the contents of a <contenteditable> component, I receive a warning:

[Vue warn]: Invalid event arguments: event validation failed for event 
"update:modelValue".
warn2 @ runtime-core.esm-bundler.js:38
emit$1 @ runtime-core.esm-bundler.js:675
(anonymous) @ runtime-core.esm-bundler.js:7388
update @ vue-contenteditable.es.js:41
callWithErrorHandling @ runtime-core.esm-bundler.js:155
callWithAsyncErrorHandling @ runtime-core.esm-bundler.js:164
invoker @ runtime-dom.esm-bundler.js:339

@hl037
Copy link
Owner

hl037 commented Nov 7, 2022

I can reproduce too.
I don't have time to investigate it right now, maybe later this week. Anyway, that's weird, and could be a vue bug : looking at the code, it seems like the event is sending a string, which is the right type...

Since it's only a warning and does not seem to affect the usability of the lib, I tagged as enhancement

@hl037 hl037 added enhancement New feature or request good first issue Good for newcomers labels Nov 7, 2022
@toniengelhardt
Copy link

Also, getting this, any news?

@hyrioo-msp
Copy link

@hl037 I just looked a bit into this.
You are actually specifying validation functions in your defineEmits:

const emit = defineEmits({
  'returned' : String,
  'update:modelValue' : String,
});

Causing vue to call String() with the empty value, which then returns an empty string to the validator instead of true/false causing the warning.
It would properly be easier just to define the emits as an array:

const emit = defineEmits(['returned', 'update:modelValue']);

Or with typescript:

const emit = defineEmits<{
    (e: 'update:modelValue', value: string): void;
    (e: 'returned', value: string): void;
}>();

Or specifying a true validator as described here: https://vuejs.org/guide/components/events.html#events-validation

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

5 participants