Issue #2738Opened April 26, 2020by adamwpe2 reactions

[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)

adamwpeMay 4, 20202 reactions

@artf Thank you!

I made an example of a working Drop Down List for anyone who comes across this.

https://jsfiddle.net/f74zqpgx/

Adam

Ju99ernautApril 27, 20200 reactions

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>`
});

fiddle

Ju99ernautApril 28, 20200 reactions

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.

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...

Browse Plugin Categories

Jump directly to plugin category pages on the marketplace.