Prevent hover highlighter and prevent selecting certain components
Hi @artf,
I would like to get your thoughts on the following 2 items before submitting a pull request. These are to satisfy requirements for a project that I'm currently working on, but I'm hoping that they could have a place in grapesjs core.
-
Prevent the hover highlight effect on certain components. Components already have a "highlightable" property that is being used for the dotted outline style. I was thinking about using that same property to prevent the hover highlight effect, but it could also be a new property (maybe "hoverable" or "highlightOnHover"?). I haven't tested it yet, but it looks like I could just check the value of the property in SelectComponent.updateHighlighter() and return early if the value is set to false.
-
Prevent selecting certain components. I would also like to completely prevent selecting certain components when they are clicked. I have some hacky code now that adds a "selectable" property to components, and if that property is set to false when the
component:selectedevent fires then I un-select it (editor.select("")). I would prefer the component to not actually get selected in the first place to prevent othercomponent:selectedlisteners from running, as well as to prevent the quick flash of the blue style outline & toolbar that briefly appears (I see this happen in chrome...not sure about other browsers). Is there an existing property that could be used for this? If not, what do you think about me adding a "selectable" property that could be used to prevent component selection?
Thanks for everything you do for this project, I really appreciate it!
- Prevent the hover highlight effect on certain components. Components already have a "highlightable" property that is being used for the dotted outline style. I was thinking about using that same property to prevent the hover highlight effect, but it could also be a new property (maybe "hoverable" or "highlightOnHover"?). I haven't tested it yet, but it looks like I could just check the value of the property in SelectComponent.updateHighlighter() and return early if the value is set to false.
hoverable approved 👍
I'd like to point out not to use camelCase naming in Model's properties as it makes them invaluable via data-gjs-* attributes.
Confirm also about your thoughts on SelectComponent.updateHighlighter
- Prevent selecting certain components. I would also like to completely prevent selecting certain components when they are clicked. I have some hacky code now that adds a "selectable" property to components, and if that property is set to false when the component:selected event fires then I un-select it (editor.select("")). I would prefer the component to not actually get selected in the first place to prevent other component:selected listeners from running, as well as to prevent the quick flash of the blue style outline & toolbar that briefly appears (I see this happen in chrome...not sure about other browsers). Is there an existing property that could be used for this? If not, what do you think about me adding a "selectable" property that could be used to prevent component selection?
I was already thinking about adding something like so go on.
Thanks to you for your help :)
Thanks for the feedback! I've created a couple of pull requests for these items, let me know if you want to discuss further.
Merged, Thanks Ryan 👍
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.