Skip to content

Commit

Permalink
Merge pull request rstudio#8542 from rstudio/bugfix/visual-editor-ace…
Browse files Browse the repository at this point in the history
…-firefox

Fix scroll/focus issue in visual editor in non-Chrome browsers
  • Loading branch information
jjallaire authored Dec 4, 2020
2 parents 6f605ce + a11f191 commit 901596a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,16 @@ public final native Element getTextInputElement() /*-{
return this.textInput.getElement();
}-*/;

/**
* Forces the use of browser focus scrolling. This is the default on Chrome, but on other
* browsers, a complicated hack involving setting the 'ace_nocontext' attribute on all parent
* elements is used instead to avoid scroll jitter. This is not necessary in embedded editors,
* and causes ProseMirror to go nuts (see issue 8518), so this hook allows us to turn it off.
*/
public final native void useBrowserInputFocus() /*-{
this.textInput.$focusScroll = "browser";
}-*/;

/**
* Set an aria-label on the input element
* @param label
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,9 @@ public FileSystemItem getActiveFile()
// Prevent tab from advancing into editor
chunkEditor.getTextInputElement().setTabIndex(-1);

// Force the use of browser APIs to set focus to the input element
chunkEditor.useBrowserInputFocus();

// Allow the editor's size to be determined by its content (these
// settings trigger an auto-growing behavior), up to a max of 1000
// lines.
Expand Down

0 comments on commit 901596a

Please sign in to comment.