WebView2Feedback icon indicating copy to clipboard operation
WebView2Feedback copied to clipboard

Spell check suggestion text is not available in ContextMenuRequested event

Open q71114 opened this issue 3 years ago • 39 comments

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 avatar Apr 06 '22 09:04 q71114

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

champnic avatar Apr 06 '22 18:04 champnic

I am also facing same issue in release build 1.0.1185.39

SDev2022 avatar May 17 '22 05:05 SDev2022

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

carlosbet avatar Jul 29 '22 09:07 carlosbet

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

MarkIngramUK avatar Mar 22 '23 14:03 MarkIngramUK

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")?

srwei avatar May 11 '23 00:05 srwei

@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.

RendijsSmukulis avatar Jun 26 '23 07:06 RendijsSmukulis

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 avatar Jul 10 '23 10:07 fvanheeswijk

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?

fvanheeswijk avatar Sep 13 '23 12:09 fvanheeswijk

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

Flaflo avatar Nov 23 '23 12:11 Flaflo

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

pdolanjski avatar Jan 25 '24 19:01 pdolanjski

Hello,

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

Thanks!

nishitha-burman avatar Jan 30 '24 00:01 nishitha-burman

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

q71114 avatar Jan 30 '24 05:01 q71114

Hello,

Can you please try with Runtime version 123.0.2377.0?

Thanks!

nishitha-burman avatar Jan 31 '24 18:01 nishitha-burman

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

dianaqu avatar Jan 31 '24 21:01 dianaqu

@nishitha-burman Using 123.0.2377.0 https://github.com/MicrosoftEdge/WebView2Feedback/issues/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?

q71114 avatar Feb 02 '24 06:02 q71114

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!

dianaqu avatar Feb 05 '24 20:02 dianaqu

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?

fvanheeswijk avatar Feb 06 '24 09:02 fvanheeswijk

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?

q71114 avatar Feb 06 '24 14:02 q71114

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

dianaqu avatar Feb 07 '24 00:02 dianaqu

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.

nirdil avatar Feb 07 '24 08:02 nirdil

@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.

dianaqu avatar Feb 07 '24 19:02 dianaqu

@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?

nirdil avatar Feb 08 '24 09:02 nirdil

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

dianaqu avatar Feb 08 '24 20:02 dianaqu

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

nirdil avatar Feb 09 '24 10:02 nirdil

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

dianaqu avatar Feb 14 '24 18:02 dianaqu

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

nirdil avatar Feb 14 '24 20:02 nirdil

@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.

q71114 avatar Feb 19 '24 14:02 q71114

@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?

nishitha-burman avatar Feb 21 '24 00:02 nishitha-burman

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?

q71114 avatar Feb 21 '24 06:02 q71114

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?

nirdil avatar Feb 21 '24 06:02 nirdil