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

Spell check suggestion text is not available in ContextMenuRequested event #2340

Open
q71114 opened this issue Apr 6, 2022 · 38 comments
Open
Assignees
Labels
bug Something isn't working tracked We are tracking this work internally.

Comments

@q71114
Copy link

q71114 commented Apr 6, 2022

Description
CoreWebView2ContextMenuRequestedEventArgs.MenuItems for CoreWebView2.ContextMenuRequested event contain list of commands with spellcheck name but there's no way to get the actual suggestion text.

Version
SDK: 1.0.1189-prerelease
Runtime: 100.0.1185.29
Framework: WPF
OS: Win11

Repro Steps

  1. Add event handler to CoreWebView2.ContextMenuRequested
  2. Start the application
  3. Right click on a misspelled word
  4. There are spellcheck commands in CoreWebView2ContextMenuRequestedEventArgs.MenuItems but there's no suggestions available for any of them. Setting their CommandId as SelectedCommandId works properly as the misspelled word will be corrected.

Screenshots
image

Additional context
Without this information it's not possible for us to build a custom context menu with spell check suggestions.

AB#45525011

@q71114 q71114 added the bug Something isn't working label Apr 6, 2022
@champnic
Copy link
Member

champnic commented Apr 6, 2022

Thanks for the bug report @q71114 - I've added this to our backlog.

@champnic champnic added the tracked We are tracking this work internally. label Apr 6, 2022
@SDev2022
Copy link

SDev2022 commented May 17, 2022

I am also facing same issue in release build 1.0.1185.39

@carlosbet
Copy link

Description
The problem still active on 1.0.1245.22 build.
And added to this bug, I do not open a new because I think this is a same issue. The simple fact of use Console.WriteLine to get feedback causes that suggestions never shown. For example:

for (int i = 0; i < e.MenuItems.Count; i++)
{
    Console.WriteLine($"{e.MenuItems[i].Name} -- {e.MenuItems[i].CommandId}");
    if (!acceptedCommandIds.Contains(e.MenuItems[i].CommandId))
    {
        e.MenuItems.RemoveAt(i);
        i -= 1;
    }
}

And now a curious behavior. If I remove Console.WriteLine, the first time that the context menu it's open, suggestions are not shown and message “getting suggestions” stay freeze, but then, on the following calls, all works fine and suggestions are shown. Even if in the first time the open menu has another kind (Page for example), the next times spell suggestions will work fine… Maybe some missing initialization?

Version
Runtime: 1.0.1245.22
Framework: NET 6.0 - WinForms
OS: Win10 x64

@MarkIngramUK
Copy link

@carlosbet , your "curious behaviour" sounds like it could be #3142

@srwei
Copy link

srwei commented May 11, 2023

When right clicking for the context menu on the misspelled word text, what are you seeing? Are there blank strings in the menu items or is there the placeholder (i.e. "Getting suggestions")?

@RendijsSmukulis
Copy link

RendijsSmukulis commented Jun 26, 2023

@srwei Following @q71114 's repro steps, we're seeing blank labels in the CoreWebView2ContextMenuRequestedEventArgs.MenuItems:

+++> Caught CoreWebView2ContextMenuRequestedEventArgs with menu items:
 +++> label: '', name: 'spellcheck', kind: 'Command'
 +++> label: '', name: 'spellcheck', kind: 'Command'
 +++> label: '', name: 'spellcheck', kind: 'Command'
 +++> label: '', name: 'other', kind: 'Separator'
 +++> label: 'Cu&t', name: 'cut', kind: 'Command'
 +++> label: '&Copy', name: 'copy', kind: 'Command'
 +++> label: '&Paste', name: 'paste', kind: 'Command'
 +++> label: 'P&aste as plain text', name: 'pasteAndMatchStyle', kind: 'Command'
 +++> label: '&Share', name: 'share', kind: 'Command'
 +++> label: '&Web capture', name: 'webCapture', kind: 'Command'
 +++> label: '', name: 'other', kind: 'Separator'
 +++> label: 'I&nspect', name: 'inspectElement', kind: 'Command'

Note that this is repro'd by handling CoreWebView2.ContextMenuRequested event, as per the original bug report.

@fvanheeswijk
Copy link

When can we expect this issue to be resolved? Without it we cannot fully integrate WebView2 in our application and this bug has been open for more than a year already...

@fvanheeswijk
Copy link

Has there been any news on this @champnic and @srwei? Spell checking still is a major issue and it seems like multiple users here are reporting these things, is a review of the spell checking API in the works?

@Flaflo
Copy link

Flaflo commented Nov 23, 2023

I also would like to know the current state of this issue. @srwei

@pdolanjski
Copy link

The spell checking APIs are currently completely broken. Because of this bug a custom context menu cannot be used (since you're left with blank labels so the spelling options cannot be displayed for users), but even if you attempt to use a non-custom context menu, because of issue 3142 the spelling suggestions just never appear.
cc @nishitha-burman @liminzhu

@nishitha-burman
Copy link
Collaborator

Hello,

A fix has been checked into Canary 123+. Can you please check if this issue is resolved for you?

Thanks!

@q71114
Copy link
Author

q71114 commented Jan 30, 2024

Hi @nishitha-burman,

Thanks for letting us know, unfortunately it still doesn't seem to work.
Here is the test I conducted using Scenario > Custom Context Menu in WebView2Samples.
You can see that the spell check suggestions are still blank:

image

@nishitha-burman
Copy link
Collaborator

nishitha-burman commented Jan 31, 2024

Hello,

Can you please try with Runtime version 123.0.2377.0?

Thanks!

@dianaqu
Copy link
Contributor

dianaqu commented Jan 31, 2024

Also note that if you switch to customized context menu live. You gonna need to refresh once to resolve the blank issue

@q71114
Copy link
Author

q71114 commented Feb 2, 2024

@nishitha-burman Using 123.0.2377.0 #3142 is solved now
image

but this issue with the customized context menu is still not fixed:
image

Also note that if you switch to customized context menu live. You gonna need to refresh once to resolve the blank issue

Hi @dianaqu, thanks for your suggestion. I tried to click on Reload after switching to customized context menu but that didn't work.
Do you mind elaborating on this please? What did you mean by You gonna need to refresh once?

@dianaqu
Copy link
Contributor

dianaqu commented Feb 5, 2024

Hi @q71114
I did some quick debugging this morning and we found a bug on using customized context menu on the fly, the related object will not be initialized. But a workaround is to start up Webview2 with enabled customized context menu and set up handlers. That way, spellcheck will work as expected, Thanks @nishitha-burman for verify that route!

@fvanheeswijk
Copy link

Unfortunately custom context menu items still do not have the spellcheck text available, I don't exactly know what you mean by your latest suggestion @dianaqu but can we expect a fix soon?

I'm also especially interested as the 1.0.2277.86 SDK update mentions "Ensured that the spellcheck language matches put_Language programmatically. The customized context menu is also updated with correct spellchecks. (Runtime-only)" which seems to be this issue, so it will be fixed in Stable 121.0.2277.86+ as well?

@q71114
Copy link
Author

q71114 commented Feb 6, 2024

a workaround is to start up Webview2 with enabled customized context menu and set up handlers

@dianaqu, I'm so sorry, but it's still not clear to me what is the workaround here. Do you mind sharing a code sample that I can try out?

@dianaqu
Copy link
Contributor

dianaqu commented Feb 7, 2024

@nishitha-burman Do you mind sharing what you tried to get it working?

@nirdil
Copy link

nirdil commented Feb 7, 2024

Was there some breaking change around this recently?
I'm using WebView2 under UWP with recent dev channel and the entire spell checking functionality is now completely missing.
It wasn't working properly in the first place (had to resort to my own spell checker to fill in the blanks in the context menu, using a custom context menu), but now it's completely missing, no red line under misspelled text, no relevant option in the context menu.

@dianaqu
Copy link
Contributor

dianaqu commented Feb 7, 2024

@nirbil yes and no. We have shipped couple fixes to ensure spellcheck works for different languages. And we noticed a bug that without using put_Language to set language to en-US, spellcheck will get disabled. The current workaround is to set language. I'm working on fixing the issue.

@nirdil
Copy link

nirdil commented Feb 8, 2024

@nirbil yes and no. We have shipped couple fixes to ensure spellcheck works for different languages. And we noticed a bug that without using put_Language to set language to en-US, spellcheck will get disabled. The current workaround is to set language. I'm working on fixing the issue.

I ensured that the default language is set to 'en-US' in the app manifest.
I suspect something was broken along the way at least on UWP as the spell check is now disabled and it used to (somewhat) work.
Should I open a new bug?

@dianaqu
Copy link
Contributor

dianaqu commented Feb 8, 2024

What version of WebView2 runtime are you using? And what channel?

@nirdil
Copy link

nirdil commented Feb 9, 2024

Latest version - 1.0.2277.86.
Checked it in both dev and standard channels.

@dianaqu
Copy link
Contributor

dianaqu commented Feb 14, 2024

121.0.2277.112 have all fixes we cherry pick. Could you update and try that?

@nirdil
Copy link

nirdil commented Feb 14, 2024

That's the current stable release channel version.
I checked it, spell checking doesn't work.

@q71114
Copy link
Author

q71114 commented Feb 19, 2024

@nishitha-burman Do you mind sharing what you tried to get it working?

@dianaqu @nishitha-burman Is there any update on this? I'd love to try out the aforementioned workaround if you could share it with me.

@nishitha-burman
Copy link
Collaborator

nishitha-burman commented Feb 21, 2024

@q71114 In the Sample app code I set m_allowCustomMenus to true (it is false by default). You can find this in SettingsComponent.h. And now am seeing spellcheck suggestions. Does this work for you?

@q71114
Copy link
Author

q71114 commented Feb 21, 2024

m_allowCustomMenus

@nishitha-burman Thanks for that. I only ever tried the WPF integration sample app (WebView2WpfBrowser) because that one resembles more to what we try to achieve and I couldn't find something similar to what you wrote. Does that mean at the moment this feature (spell check suggestion using custom menu) won't work with the WPF integration?

@nirdil
Copy link

nirdil commented Feb 21, 2024

Was there some breaking change around this recently? I'm using WebView2 under UWP with recent dev channel and the entire spell checking functionality is now completely missing. It wasn't working properly in the first place (had to resort to my own spell checker to fill in the blanks in the context menu, using a custom context menu), but now it's completely missing, no red line under misspelled text, no relevant option in the context menu.

Should I start a separate regression bug for WinUI2/UWP?

@dianaqu
Copy link
Contributor

dianaqu commented Feb 21, 2024

Was there some breaking change around this recently? I'm using WebView2 under UWP with recent dev channel and the entire spell checking functionality is now completely missing. It wasn't working properly in the first place (had to resort to my own spell checker to fill in the blanks in the context menu, using a custom context menu), but now it's completely missing, no red line under misspelled text, no relevant option in the context menu.

Should I start a separate regression bug for WinUI2/UWP?

We have a internal item tracking this

@dianaqu
Copy link
Contributor

dianaqu commented Feb 23, 2024

m_allowCustomMenus

@nishitha-burman Thanks for that. I only ever tried the WPF integration sample app (WebView2WpfBrowser) because that one resembles more to what we try to achieve and I couldn't find something similar to what you wrote. Does that mean at the moment this feature (spell check suggestion using custom menu) won't work with the WPF integration?

In WPF you can do something like this webView.CoreWebView2.ContextMenuRequested += WebView_ContextMenuRequested; during initialization
and in WebView_ContextMenuRequested do customize context menu stuff

@dianaqu
Copy link
Contributor

dianaqu commented Feb 24, 2024

@nirbil @q71114
Quick questions to folks. Are you trying to paint your own context menu or just trying to remove item from browser context menu.
If you are painting your own context menu, spellcheck is not yet supported. We have a backlog item to add new API to support retrieving spellcheck suggestions.
But if you don't paint your own context menu, rather just remove/add item from the existing browser context menu. Spellcheck is supported in this case.

Note that our sample app is painting context menu for text selection cases. So if you try it in sample app, spellcheck won't be available

@fvanheeswijk
Copy link

@dianaqu We're using our own context menu so we'd really appreciate it if the spellcheck suggestions would be available as soon as possible.

@q71114
Copy link
Author

q71114 commented Feb 26, 2024

Are you trying to paint your own context menu or just trying to remove item from browser context menu.

We do the former.

If you are painting your own context menu, spellcheck is not yet supported. We have a backlog item to add new API to support retrieving spellcheck suggestions. But if you don't paint your own context menu, rather just remove/add item from the existing browser context menu. Spellcheck is supported in this case.

Just to clarify this means this bug is still not fixed as you have a separate backlog item for it. The one you fixed is this issue: #3142

@dianaqu
Copy link
Contributor

dianaqu commented Feb 27, 2024

Just to clarify this means this bug is still not fixed as you have a separate backlog item for it. The one you fixed is this issue: #3142

Yes. It's a separate issue from #3142. We fixed the spellcheck for using browser context menu since that don't require any SDK change. for painting your own context menu, that require a bit more change

@fvanheeswijk
Copy link

Just to clarify this means this bug is still not fixed as you have a separate backlog item for it. The one you fixed is this issue: #3142

Yes. It's a separate issue from #3142. We fixed the spellcheck for using browser context menu since that don't require any SDK change. for painting your own context menu, that require a bit more change

Is there any news on when this will be fixed?

@nirdil
Copy link

nirdil commented Sep 20, 2024

Just to clarify this means this bug is still not fixed as you have a separate backlog item for it. The one you fixed is this issue: #3142

Yes. It's a separate issue from #3142. We fixed the spellcheck for using browser context menu since that don't require any SDK change. for painting your own context menu, that require a bit more change

Is this currently worked on is it in the backlog?
I don't think that fixing the spellcheck on a custom context menu (which most companies probably use) requires any SDK changes. The item's label attribute just need to be filled out with the suggestion rather then be left blank as it currently is.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working tracked We are tracking this work internally.
Projects
None yet
Development

No branches or pull requests