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

WinForms - text input Autofocus not works #4965

Open
1 task done
I-Iege opened this issue Oct 25, 2024 · 7 comments
Open
1 task done

WinForms - text input Autofocus not works #4965

I-Iege opened this issue Oct 25, 2024 · 7 comments
Labels

Comments

@I-Iege
Copy link

I-Iege commented Oct 25, 2024

Is there an existing issue for this?

  • I have searched both open/closed issues, no issue already exists.

CefSharp Version

129.0.110

Operating System

Windows 11

Architecture

x64

.Net Version

.Net 6.0

Implementation

WinForms

Reproduction Steps

  1. We have a page with text input which set to focus on page load.
  2. open the url with sefsharp winform example browser

Expected behavior

The text input is in fully focused, it is possible to type text after the page loaded.

Actual behavior

The text input has focused style, but has no caret not possible to type.

Regression?

No response

Known Workarounds

No response

Does this problem also occur in the CEF Sample Application

Yes using WPF/OffScreen command line args

Other information

the text input is HTMLInputElement
the page build with node 22.9.0
we have :
"@types/react-dom": "^17.0.11",
"react-dom": "^17.0.2",

@dbuechel
Copy link

dbuechel commented Oct 25, 2024

We have actually just recently stumbled upon this as well, the input focus used to work fine for us using the Windows Forms control when manually focusing the IBrowserHost: SafeExamBrowser/seb-win-refactoring@40d2709.

if (control.IsBrowserInitialized)
{
	control.BrowserCore.GetHost().SetFocus(true);
}

This however appears to have stopped working as it appears.

@dbuechel
Copy link

dbuechel commented Oct 25, 2024

I was just able to resolve the issue using a custom focus handler: SafeExamBrowser/seb-win-refactoring@e8ebb21. It may however be that the default handler still has a bug, as the input focus indeed was not working anymore as explained above.

@I-Iege
Copy link
Author

I-Iege commented Oct 30, 2024

I was just able to resolve the issue using a custom focus handler: SafeExamBrowser/seb-win-refactoring@e8ebb21. It may however be that the default handler still has a bug, as the input focus indeed was not working anymore as explained above.

Can we have that in a newer seb version?

@dbuechel
Copy link

Can we have that in a newer seb version?

Yes, the fix will be released with the upcoming version 3.9.0.

@amaitland
Copy link
Member

  • We have a page with text input which set to focus on page load.
  • open the url with sefsharp winform example browser

@I-Iege Please provide more detail steps. Making sure to clarify which example you are using, there are multiple.
Please also include a Url you are testing with (preferably something like github, google, microsoft, etc)

e.g.

  • Open CefSharp.WinForms.Example
  • Navigate to github.com
  • Observe

We have actually just recently stumbled upon this as well, the input focus used to work fine for us using the Windows Forms control when manually focusing the

Probably issue chromiumembedded/cef#3436 (comment)

Switching to the WinForms UI thread and calling Focus was required. Calling SetFocus directly in the CEF callback was doing strange things.

https://github.com/cefsharp/CefSharp.MinimalExample/blob/master/CefSharp.MinimalExample.WinForms/BrowserForm.cs#L81

It may however be that the default handler still has a bug

It hasn't changed in years, it's possible that it needs changes if Chromium behavior has changed.

Pull request would be welcome.

@amaitland amaitland changed the title text input Autofocus not works in winforms WinForms - text input Autofocus not works Nov 1, 2024
@I-Iege
Copy link
Author

I-Iege commented Nov 2, 2024

I primarily tested this with our internal webpage, but opening google has similar issue.

  • Open CefSharp.WinForms.Example
  • navigate to https://duckduckgo.com (can be reproduce with google too but have to store cookies first)
  • not possible to type

@dbuechel
Copy link

dbuechel commented Nov 4, 2024

Probably issue chromiumembedded/cef#3436 (comment)

Switching to the WinForms UI thread and calling Focus was required. Calling SetFocus directly in the CEF callback was doing strange things.

https://github.com/cefsharp/CefSharp.MinimalExample/blob/master/CefSharp.MinimalExample.WinForms/BrowserForm.cs#L81

It may however be that the default handler still has a bug

It hasn't changed in years, it's possible that it needs changes if Chromium behavior has changed.

Pull request would be welcome.

Thanks for the additional information and context; I did suspect that it was an upstream issue. Luckily, the implementation of a custom focus handler has resolved the issue for us.

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

No branches or pull requests

3 participants