suren-atoyan / monaco-react

Monaco Editor for React - use the monaco-editor in any React application without needing to use webpack (or rollup/parcel/etc) configuration files / plugins
https://monaco-react.surenatoyan.com/
MIT License
3.52k stars 258 forks source link

Request for Editor.focus method optional params support #554

Open ivanksh opened 8 months ago

ivanksh commented 8 months ago

It would be great if Editor.focusmethod supported optional params (preventScroll, focusVisible - https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/focus#parameters) and used these params when focusing in editor textarea

The reason: We are using Editorinside nodes within some canvas and have the feature of auto focusing Editor within newly added node. As by default preventScrollis false this causes unintentional browser scrolling the document to bring the newly-focused element into view and this is the reason for some UI issues. IfEditor.focus supports preventScroll parameter we can easily control browser behavior on focus

suren-atoyan commented 7 months ago

editor.focus isn't implemented by this library, you should refer to the base monaco-editor library