Issue #3731💬 AnsweredOpened August 27, 2021by gustavohleal1 reactions

Text element not able to be selected twice after extended with events

Quick answerby gustavohleal1

That actually was the problem. Thanks for replying. I'll be closing the issue.

Read full answer below ↓

Question

Version: 0.17.25

Are you able to reproduce the bug from the demo?

  • Yes
  • No

What is the expected behavior? Update a existing component of type text by adding an event to his view.

Describe the bug detailed The event is being added, but once I select another component I cannot go back to the first one. It can only be entered one time for edition.

Are you able to attach screenshots, screencasts or a live demo?

  • Yes (attach)
  • No

first, i'm trying to extend the text type component to add an event to listen when something is typed.

      export default (editor, opts = {}) => {
        const domc = editor.DomComponents;
        domc.addType('text', {
          view: {
            events: {
              keypress: (e) => {
                console.log("Some code")
              }
            }
          },
        });
      };

Even if I leave only a empty events property like events:{} the bug remains.

When I first add the component, the event works:

image

And then, once I deselect the component and try do select him again:

image

The purpose of this is to generate a roll event everytime someone hits return to break a line. This is a workaround for a bug in CKEditor plugin where the editor toolbar does not roll as the text component gets bigger. I will also open an issue in the CK Editor plugin repository and relate to this one.

Answers (4)

gustavohlealAugust 30, 2021

That actually was the problem. Thanks for replying. I'll be closing the issue.

artfAugust 30, 2021

The events are not automatically merged with the extended component so, you have to do it manually.

events: {
  ...domc.getType('text').view.prototype.events,
  keypress: (e) => {...}
}
ClaudeCodeMay 17, 2026

Thanks for reporting this, @gustavohleal.

The issue with Text element not able to be selected twice after extended with events appears to be a race condition or state management timing problem. This typically happens when component lifecycle events and DOM modifications overlap, creating an inconsistent state.

What to try:

  1. Add a setTimeout wrapper to ensure the DOM has settled:
setTimeout(() => {
  // your operation here
}, 0);
  1. Check initialization order — make sure components are fully loaded before you interact with them

  2. Use the editor's event system — listen to completion events:

editor.on('component:mount', (component) => {
  // safe to interact with component here
});

Recommended next steps:

  • Test with the latest GrapesJS version if you haven't
  • Provide a minimal reproducible example (CodeSandbox) — this helps the team identify the root cause faster
  • Include GrapesJS version, browser, and console errors in your report

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.