BUG: Resizable Box Disappears on Component Reselection
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
- Open GrapesJS with the provided HTML code.
- Select any component on the canvas to see the bottom resize box.
- Click the same component again.
- 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 (3)
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 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:
- When clicking directly on the section, the bottom resizable options are displayed as expected.
- 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.
Trust me, I was lucky that I was able to find this tragic behavior of clicking different places inside section was behaving but different.
I don't see it disappearing if not when you press the click but that is expected as it gets ready to be dragged
Related Questions and Answers
Continue research with similar issue discussions.
Issue #4323
BUG: Performance issue while dragging component to canvas when you have 2k component on canvas
GrapesJS version[X] I confirm to use the latest version of GrapesJSWhat browser are you using? Google Chrome Version 101.0.4951.41 (Officia...
Issue #6458
BUG: sector.setName doesn't work
GrapesJS version [x] I confirm to use the latest version of GrapesJS What browser are you using? Chrome Reproducible demo link https://jsfi...
Issue #5990
BUG: When you delete a component, duplicate classes between components will be deleted.
GrapesJS version [X] I confirm to use the latest version of GrapesJS What browser are you using? Chrome 126.0.6478.127(Windows) Reproducibl...
Issue #5705
BUG: Component tools misalign when the editor is resized
GrapesJS version [X] I confirm to use the latest version of GrapesJS What browser are you using? Chrome v122 Reproducible demo link https:/...
Paid Plugins That Match This Issue
Curated by issue keywords and label relevance to help you ship faster.
Loading paid plugin recommendations...
Browse Plugin Categories
Jump directly to plugin category pages on the marketplace.