Issue #6096πŸ’¬ AnsweredOpened August 30, 2024by kanaihyakumar2 reactions

Resizable Box Disappears on Component Reselection

Quick answerby kanaihyakumar❀ 1

Earlier, I needed to be more clearer about the steps to reproduce the issue. Here is the refined steps to produce the issue. Steps to Reproduce the Issue:Click on the section directly.Observe the resizable options displayed.Click in an area within the section where there is a column component(I have added a border to...

Read full answer below ↓

Question

GrapesJS version

  • I confirm to use the latest version of GrapesJS

What browser are you using?

Chrome

Reproducible demo link

https://jsfiddle.net/kanaihyakumar/oedg76nt/

Describe the bug

Description

When selecting any component on the canvas, it highlights the bottom resize box as per the settings. However, upon clicking the same component again, the resize box disappears.

Steps to Reproduce

  1. Open GrapesJS with the provided HTML code.
  2. Select any component on the canvas to see the bottom resize box.
  3. Click the same component again.
  4. Observe that the resize box disappears.

Expected Behavior

The bottom resize box should remain visible even after reselecting the same component.

Actual Behavior

The bottom resize box disappears after reselecting the same component.

Code

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
    <link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet">
    <script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"></script>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.7.1/jquery.min.js"></script>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/grapesjs/0.21.12/css/grapes.min.css">
    <script src="https://cdnjs.cloudflare.com/ajax/libs/grapesjs/0.21.12/grapes.min.js"></script>
    <script src="https://unpkg.com/[email protected]"></script>
    <style>
        html,
        body {
            margin: 0;
            padding: 0;
        }
    </style>
</head>
<body>
    <main>
        <div id="gjs"></div>
    </main>
    <script>
        const htmlContent = `
           <style>
    .banner {
        height: 480px;
        color: #ffffff;
    }
    
    .banner__container {
        padding-top: 6%;
        padding-left: 15%;
        padding-bottom: 10%;
    }
    
    .banner__headline {
        font-family: Figtree;
    }
    
    @media (max-width:767px) {
        .banner {
            height: 350px;
        }
        .banner__container {
            padding-left: 5%;
        }
    }
    
    @media (max-width:480px) {
        .banner {
            height: 250px;
        }
    }
    </style>
    <section class="banner attribute" style="background-image: linear-gradient(#023f8080, #023f8080), url(https://images.pexels.com/photos/27308359/pexels-photo-27308359/free-photo-of-pigeons-on-a-tree.jpeg?auto=compress&cs=tinysrgb&w=1260&h=750&dpr=1); background-position: top left; background-size: cover; background-repeat: no-repeat;">
        <div class="banner__container container-fluid column">
            <h2 class="banner__headline mb-4 fs-1">The birds are the eye of someone special</h2>
        <a class="banner__button btn button-variable px-5 py-1" role="button">Click</a>
        </div>
    </section>
        `;
       
        const editor = grapesjs.init({
            container: '#gjs',
            fromElement: true,
            height: '100vh',
            width: 'auto',
            plugins: ['gjs-blocks-basic'],
            storageManager: false,
        });
        editor.DomComponents.addType('section', {
            isComponent: el => el.tagName === 'SECTION',
            model: {
                defaults: {
                    tagName: 'SECTION',
                    draggable: 'main',
                    droppable: false,
                    highlightable: false,
                    name: 'Section',
                    dmode: '',
                    resizable: {
                        tl: 0,
                        tc: 0,
                        tr: 0,
                        cr: 0,
                        cl: 0,
                        bl: 0,
                        bc: 1,
                        br: 0
                    }
                }
            }
        });
        editor.DomComponents.addType('column', {
            extend: 'default',
            isComponent: el => el.classList && el.classList.contains("column"),
            model: {
                defaults: {
                    tagName: 'DIV',
                    draggable: false,
                    droppable: true,
                    attributes: {},
                    name: 'Column',
                    editable: true,
                    hoverable: false,
                    selectable: false,
                    layerable: false,
                    highlightable: false,
                    removable: false
                }
            },
        });
        const mainComponent = editor.setComponents(htmlContent);
        let sectionComponent = editor.getComponents().models[0];
        editor.on('component:selected', (component) => {
            const selected = editor.getSelected();
            if (selected) {
                selected.set({
                    draggable: true,
                    droppable: true,
                    resizable: {
                        tl: 0,
                        tc: 0,
                        tr: 0,
                        cl: 0,
                        cr: 0,
                        bl: 0,
                        bc: 1,
                        br: 0,
                    },
                });
            }
        });
    </script>
</body>
</html>


### Code of Conduct

- [X] I agree to follow this project's Code of Conduct

Answers (4)

kanaihyakumarβ€’ September 2, 2024

Earlier, I needed to be more clearer about the steps to reproduce the issue. Here is the refined steps to produce the issue.

Steps to Reproduce the Issue:

  1. Click on the section directly.
  2. Observe the resizable options displayed.
  3. Click in an area within the section where there is a column component(I have added a border to all elements in the provided video for clarity). Observe the section component is selected but the bottom resizable option is not showing. Video Link

Actual Behavior:

  1. When clicking directly on the section, the bottom resizable options are displayed as expected.
  2. However, when clicking on an area where a column component is present, the section is selected but the bottom resizable options are not displayed.

Expected Behavior:

When clicking anywhere inside the section, if the clicked point does not include any selectable component, the section should be selected and the bottom resizable options should be displayed.

kanaihyakumarβ€’ September 6, 2024

Trust me, I was lucky that I was able to find this tragic behavior of clicking different places inside section was behaving but different.

artfβ€’ August 31, 2024

I don't see it disappearing if not when you press the click but that is expected as it gets ready to be dragged

ClaudeCodeβ€’ May 17, 2026

Thanks for reporting this, @kanaihyakumar.

The issue with Resizable Box Disappears on Component Reselection 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 β†’

Browse Plugin Categories

Jump directly to plugin category pages on the marketplace.