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

V-model not work when content is setted to empty #484

Open
overbost opened this issue Jan 6, 2024 · 4 comments
Open

V-model not work when content is setted to empty #484

overbost opened this issue Jan 6, 2024 · 4 comments
Labels
wontfix This will not be worked on

Comments

@overbost
Copy link

overbost commented Jan 6, 2024

Version
@vueup/vue-quill 1.2.0

Describe the bug
When content is empty string, the quill content is not updated. The content is on the previous state
I must use
this.$refs.quillEdtor.setHTML("")

To Reproduce
Steps to reproduce the behavior:

<QuillEditor
 data-cy="textarea-full-desc"
 ref="quillEditor
 v-model:content="translation.full_desc"
 :placeholder="t('NO_FULL_DESC')"
 contentType="html"
 >

DevTools
content:""
contentType:"html"
enable:true
globalOptions:Object
modules:Object
theme:"snow"
modules:undefined
options:undefined
placeholder:"Aggiungi una descrizione dettagliata"
readOnly:false
theme:"snow"
toolbar:undefined

Expected behavior
The content should setted to empty

Additional context
I think there is a bug on the code

@Penggeor
Copy link

@axolo Worth to fix:

 watch(
      () => props.content,
      (newContent) => {
        if (!quill || !newContent || internalModelEquals(newContent)) return 👈👈👈👈👈

        // Restore the selection and cursor position after updating the content
        const selection = quill.getSelection()
        if (selection) {
          nextTick(() => quill?.setSelection(selection))
        }
        setContents(newContent)
      },
      { deep: true }
    )

@Xeyos88
Copy link

Xeyos88 commented Feb 28, 2024

This problem makes it impossible to use it within a form.
It is not possible to check whether the content is empty

@maksimzinchuk
Copy link

try this to check if content is empty
function isEmpty(value: string) { return value.replace(/<(.|\n)*?>/g, "").trim().length === 0; }

Copy link

stale bot commented May 26, 2024

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix This will not be worked on label May 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
wontfix This will not be worked on
Projects
None yet
Development

No branches or pull requests

4 participants