grapesjs icon indicating copy to clipboard operation
grapesjs copied to clipboard

[Bug] Link element selection shows no toolbar

Open devgru opened this issue 6 years ago • 8 comments

Steps to reproduce: add Text, select a word, click on Link icon in RTE panel, select a Link.

Expected behaviour: when I select Link I expect it to display toolbar (with 'select parent' button) alongside its badge.

Actual behaviour: If a link was in startup HTML, Link is properly initialised and selecting it results in both badge and toolbar being displayed. Otherwise, if a Link was created via RTE button selecting it results in just badge being displayed.

devgru avatar Aug 15 '19 13:08 devgru

May you provide a reproducible demo?

zgover avatar Aug 15 '19 17:08 zgover

Problem can be seen on any Grapes page, e.g. https://grapesjs.com/demo.html Just create new Link (it will have no toolbar), refresh the page and you can see Link gets its toolbar. BTW, if you then create new Link within same parent, there will be no toolbar for both of them.

devgru avatar Aug 16 '19 08:08 devgru

So, here's default heading: Screenshot 2019-08-16 11 58 54

Creating a Link: Screenshot 2019-08-16 11 59 04

Refreshing the page: Screenshot 2019-08-16 11 59 12

Adding another Link: Screenshot 2019-08-16 11 59 22

First one lost its toolbar: Screenshot 2019-08-16 11 59 28

Refreshing the page, links got their toolbars back: Screenshot 2019-08-16 11 59 39

devgru avatar Aug 16 '19 09:08 devgru

Yeah, I'm aware of this, you have to unfocus from the text editor because of the parser triggering on blur. Hope to improve this soon...

artf avatar Aug 24 '19 18:08 artf

@artf It also applies to any editing that is made within the same text block, for example if you go back and edit a portion of the text and blur, any other content inside will not have the toolbars.

Is there a manual way to fix this for the moment until it is improved?

simplecommerce avatar Dec 23 '19 13:12 simplecommerce

Hi @artf @simplecommerce @devgru Any update on this. Is there any way to fix this manually? Thanks

Abhisheknanda1344463 avatar Oct 13 '21 07:10 Abhisheknanda1344463

@Abhisheknanda1344463

Hi @artf @simplecommerce @devgru Any update on this. Is there any way to fix this manually? Thanks

I am not sure if it will work for you but this is what I did to work around it.

    editor.on('component:selected', function(model) {
      // if no toolbar detected, call init (i am using isEmpty from lodash) but you can just validate this without it
      if (isEmpty(model.attributes.toolbar)) {
          model.initToolbar();
      }
    }); 

simplecommerce avatar Oct 13 '21 10:10 simplecommerce

@simplecommerce Thank you Man. It's worked. Thanks

Abhisheknanda1344463 avatar Oct 13 '21 13:10 Abhisheknanda1344463

Closing the issue as it seems to be fixed.

artf avatar Jul 26 '23 12:07 artf