Issue #3604💬 AnsweredOpened July 9, 2021by NoumanAhmad-Braqsol0 reactions

Editor.on('component:update:content', model => { }}) not work in some cause

快速解答by artf

As already suggested here https://github.com/artf/grapesjs/issues/3603#issuecomment-885305546 avoid doing what you're doing now and add a simple default CSS in case the element is empty

Read full answer below ↓

Question

if the user remove all text from a element and click some where else . then again try to select empty element he is not able to select it again because it is hide and i dont know where it goes. So for this issue I am using this code

editor.on('component:update:content', model => {
const val = model.get('content');
if(val && val.length < 1){
model.set('content', '&nbsp');
}
})

this code set a space in text if user remove all text from a element . By doing this these is no empty element so i does not hide . and again we can select it . if the user remove text character one by one it works fine . But now issue is that if a user select a text by CTRL + A and remove by BACKSPACE . At this time this above code not work . Can anyone help me .

Answers (3)

NoumanAhmad-BraqsolJuly 29, 2021

Thank you i got it !

ClaudeCodeMay 17, 2026

Thanks for reporting this, @NoumanAhmad-Braqsol.

Thanks for sharing your report about editor.on('component:update:content', model => { }}) not work in some cause. To help the team investigate and prioritize this:

Please provide:

  1. A minimal reproducible example (CodeSandbox/JSFiddle)
  2. Your GrapesJS version number
  3. Browser and OS information
  4. Any error messages from the browser console
  5. Steps to reproduce the issue

What helps most:

  • Minimal code example (not your full project)
  • Screen recording or screenshot showing the issue
  • Expected vs actual behavior clearly stated
  • GrapesJS configuration you're using

With these details, the maintainers can identify and prioritize a fix much faster. The GrapesJS team is very responsive to well-documented issues.

Related Questions and Answers

Continue research with similar issue discussions.

Paid Plugins That Match This Issue

Curated by issue keywords and label relevance to help you ship faster.

View all plugins

Loading paid plugin recommendations...

Free option

Check the open-source GrapesJS plugins on GitHub or run a quick search in our free catalog.

Browse free plugins →
Premium option

Premium plugins ship with support, regular updates, and production-ready features — save days of integration work.

Browse premium plugins →

Related tutorials

In-depth guides on the same topic.

All tutorials →

Browse Plugin Categories

Jump directly to plugin category pages on the marketplace.