microsoft / microsoft/monaco-editor

[Feature Request] Request for Editor.focus method optional params support

Open
#4,248 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

editor-core feature-request
Dominant language
JavaScript
Stars
46.8k
Forks
4.1k
Avg merge
17h 58m
Merged PRs (30d)
1

Description

Context
  • This issue is not a bug report. (please use a different template for reporting a bug)
  • This issue is not a duplicate of an existing issue. (please use the search to find existing issues)
Description

It would be great if Editor.focus method 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 Editor inside nodes within some canvas and have the feature of auto focusing Editor within newly added node.
As by default preventScroll is 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. If Editor.focus supports preventScroll parameter we can easily control browser behavior on focus

Monaco Editor Playground Link

No response

Monaco Editor Playground Code

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the Editor.focus entry point and trace where it focuses the editor textarea. Check the existing browser focus call against the requested HTMLElement.focus parameters; done means preventScroll and focusVisible can be passed optionally and used when the editor receives focus.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, typescript
Domain
api, frontend
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
64/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.