Issue #921Opened March 2, 2018by dmmprog1 reactions

[QUESTION] Select and focus an html element from a panel button

Question

Code SnippetTEXT
Hi everyone,

Is it possible to set focus in a section html with Grapes, like as an anchor? I have a panel button and it just select the section that I want but not focus to element. Here is the code:

       panel.addButton('options', [{
            id: 'link',
            className: 'fa fa-th-list',            
            command: function linkChap(e) {
                editor.DomComponents.getWrapper().find('section').forEach(model => {
                    const current = model.getAttributes()['id'] || '';
                    if(current == "chap10"){
                      editor.select(model);   //Here just select the section, but not set focus
                    }
                  });
            }

Thanks in advance.
Regards.

Answers (3)

artfMarch 4, 20181 reactions

If for focus you mean scrolling the view to the component, unfortunately, there is no such a method, but you can actually implement it by relying on editor.Canvas.getBody().scrollTop

Amir2828June 18, 20190 reactions

Did you manage to make it work?

lock[bot]June 25, 20200 reactions

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.

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.