-
Notifications
You must be signed in to change notification settings - Fork 34.5k
Add iframe search with debounce #125856
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 iframe search with debounce #125856
Conversation
An issue with the CI seems to be that it's not taking in the proper Electron. |
Verified that in the case of an IME (e.g. for Mandarin), the search must be made explicit, e.g. by pressing enter, otherwise focus is lost from the IME. CC @rebornix Meanwhile when using NVDA, the readout is very different than in stable, or in the Monaco editor. In the editor, NVDA starts reading the document from the active match. In stable, NVDA only reads what is being typed in the find box. With this PR, when searching in an iframe, NVDA sometimes says "virtual document" and starts reading the iframe from the beginning, due to focus being lost from the inputbox for long enough to trigger the screenreader. Other times, NVDA only reads what is typed. @isidorn I'm wondering how to make the search behaviour more accessible here? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code changes look good overall. Nice work! Just a few minor comments
src/vs/workbench/contrib/webview/electron-sandbox/iframeWebviewElement.ts
Show resolved
Hide resolved
src/vs/workbench/contrib/webview/electron-sandbox/iframeWebviewElement.ts
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👏 👏 👏
Gave some feedback inline. Also found one potential issue: I cannot hit Cmd+X
to cut/clear the input of the find input box. Also Cmd+C
and Cmd+V
do not seem to work there, maybe something that is still missing?
src/vs/workbench/contrib/webview/electron-sandbox/iframeWebviewElement.ts
Outdated
Show resolved
Hide resolved
@rzhao271 thanks for the ping. I see there are already quite some discussions here so for accessibility I think the best would be that once we merge this in you create an issue for accessibility and we look into that together. Once this is merged it will also be easier for me to try it out. |
@bpasero I can confirm that the cut, copy, and paste commands don't work, but I'm not sure why, yet. I notice there's this event handler that is run when I type Ctrl+X, but I'm not sure if it interferes in any way https://github.com/microsoft/vscode/blob/main/src/vs/base/browser/ui/findinput/findInput.ts#L215. @mjbvz do you have any insights on this? Also, with the IME issue, if we switch webviews to iframes on Insiders, searching will fail for anyone using an IME (Chinese, Japanese, Korean languages require these, for example). Therefore, I think we can merge this to Insiders, but I wouldn't set iframes to be used by default for now. @isidorn I can create an issue for accessibility after this PR gets merged. I think the IME issue is another blocker, though. Edit again: The active match should be highlighted orange. I'm not sure why the match colour seems to alternate between yellow and orange above. |
Another issue: OSS seems to crash when I do a search in the preview view, but then change the content in the source markdown file. |
The match colour alternating between yellow and orange is an artifact of the find-in-frame implementation: The crash described in #125856 (comment) is irregular, though, and requires I make a crashdump. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚢 it
What are the steps to get to this crash? When you say OSS you mean running with our internal builds? |
I confirmed the iframe search crash occurs around the time the
I tried adding some code that stopped the find before that message was posted, but the crash continued to occur. |
👍 , I have extracted #126729 for the crash. I found a second case where I can reproduce a crash. |
c4b12a4
to
4da1d00
Compare
I have rebased the changes on top of Deepak's FindRequestManager fix, which now avoids the crash described in #126729. I also added on a commit that adds on |
This PR fixes #96307 by adding an iframe search prototype. It uses electron/electron#28274 to search in the iframe, which results in a loss of focus during the search. Therefore, I added an event to re-focus the inputbox after find results are returned, and also added a debounce so that the focus-changing behaviour of the find call is not too obvious.
Preview:

Issues: