Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a workaround for browser bug #242459

Merged
merged 2 commits into from
Mar 4, 2025
Merged

Add a workaround for browser bug #242459

merged 2 commits into from
Mar 4, 2025

Conversation

alexdima
Copy link
Member

@alexdima alexdima commented Mar 3, 2025

The browser is incorrectly sending 2 focus events

Ref #12384

@alexdima alexdima requested a review from aiday-mar March 3, 2025 12:04
@alexdima alexdima self-assigned this Mar 3, 2025
@alexdima alexdima enabled auto-merge (squash) March 3, 2025 12:04
@vs-code-engineering vs-code-engineering bot added this to the March 2025 milestone Mar 3, 2025
@aiday-mar
Copy link
Contributor

aiday-mar commented Mar 4, 2025

I have been testing this PR and I noticed that it fails on the CSS smoke test. I was able to reproduce this on a real life example. The issue is as follows:

  • Reload the code OSS window
  • Open the JSON user settings
  • Click on the right arrow (the arrow does not move)

This happens because the textInputFocus context key is set to false even though the focus is inside of the editor. The reason it is false, is because it is not correctly updated when the editor looses focus and gains it again. Normally the sequence is as follows:

onFocusChange after focus ->
isFocused from edit context is true

onFocusChange after blur ->
isFocused from edit context is false

In our case, there is a discrepancy between the two states. We can not trust that the focus tracker in the codeEditorWidget.ts file correctly reflects the focus change state on the edit context. We have instead the following sequence.

onFocusChange after focus ->
isFocused from edit context is false

onFocusChange after blur ->
isFocused from edit context is true

In other words there is a discrepancy between the focus state stored inside of the CodeEditorWidgetFocusTracker and the focus state stored inside of the view.ts file.

@aiday-mar
Copy link
Contributor

After some more investigation, it would seem that the bug happens when the CodeEditorWidget detects there is a focus event and the native edit context is focused. It asks for the focus state directly from the NativeEditContext, and the latter replies that it is not focused, even though it is. A fix can be to refresh the focus state on asking for the focus state. This would be a minimal fix.

@alexdima alexdima merged commit 4537390 into main Mar 4, 2025
8 checks passed
@alexdima alexdima deleted the alexd/strange-turkey branch March 4, 2025 16:18
aiday-mar added a commit that referenced this pull request Mar 5, 2025
aiday-mar added a commit that referenced this pull request Mar 5, 2025
Revert "Add a workaround for browser bug (#242459)"

This reverts commit 4537390.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants