[QUESTION] Keep Hover state when amending the child
Question
I'm trying to edit a dropdown list option, and it's quite difficult to style it because you cannot move your mouse to the Style Manager since the hover will disappear. So is there a way to keep the hover state active when amending a child?
I know you can style using the Layer Manager - but that's not as user friendly, just wondering if anyone has discovered a nice work around this issue.
Made a super simple demo of the problem. https://jsfiddle.net/3g8yd9tL/
Answers (3)
@artf Thank you!
I made an example of a working Drop Down List for anyone who comes across this.
https://jsfiddle.net/f74zqpgx/
Adam
Had tried this, but realized you can only edit the styles for the hover state.
<div id="gjs">
<div style="padding: 25px">Hello World!!!</div>
<style>
:root{
--display: none;
}
.dropbtn {
background-color: #4CAF50;
color: white;
padding: 16px;
font-size: 16px;
border: none;
}
.dropdown {
position: relative;
display: inline-block;
}
.dropdown-content {
display: block;
position: absolute;
background-color: #d42020;
min-width: 160px;
box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
z-index: 1;
}
.dropdown-content a {
color: black;
padding: 12px 16px;
text-decoration: none;
display: var(--display);
}
.dropdown-content a:hover {
background-color: #ddd;
--display: block;
}
.dropdown:hover {--display: block;}
</style>
</div>
const editor = grapesjs.init({
container: '#gjs',
fromElement: 1,
height: '100%',
storageManager: { type: 0 },
plugins: ['gjs-blocks-basic']
});
editor.BlockManager.add("dropdown-menu-in-navbar",
{
label: 'Dropdown Menu',
tab: "1",
category: "Others",
type: "default",
attributes: {
class: 'fa fa-ellipsis-h',
title: 'Insert Dynamic Menu of Navigation'
},
content: `
<div class="dropdown">
<button class="dropbtn">Dropdown</button>
<div class="dropdown-content">
<a class="dropdown-content-a" href="#">Link 1</a>
<a class="dropdown-content-a" href="#">Link 2</a>
<a class="dropdown-content-a" href="#">Link 3</a>
</div>
</div>`
});
You can also just select the div.dropdown-content and set its display to block in the Style Manager then set it back to none when you finish editing.
Related Questions and Answers
Continue research with similar issue discussions.
Issue #3294
FEAT: Adding options to properties list array in style manager
Hi, How can I add buildProps to properties list such that when an option is selected, the properties of that option will be displayed An ex...
Issue #1318
Question: How to enable Event of mouse to increase value of input
hi @artf I want to know Is there any way to enable input mouse scroller in style manager as you can my screenshot. i want to initalize scro...
Issue #2990
QUESTION: Is there a way to use different variations of the same style property?
Note: This is in the context of the Style Manager. Is there a way to use different variations of the same style property? For example when...
Issue #2936
QUESTION: Inline style loads on id instead of class
Hello, I have been using your tool for a while and I decided to upgrade to a newer version(from v0.12.37 to v0.16.3 + gjs-preset-newsletter...
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.