Repository: nvaccess/nvda

Issue:
new emoji panle on windos 11 isn't accessible for nvda.
new emoji panle on windos 11 isn't accessible with screen reader.
### Steps to reproduce:
1- load windos or any other app like notepad that you want to write some emojies.
2- press windos key +full stop .
3- press any key to navigate throo emojis.
### Actual behavior:
it is saying blank and you can not press enter on a emoji to write.
### Expected behavior:
it has to navigate throo emojis and read the emojis and when you press the enter key it has to write the emojis on the notepad or any other word processer that you are in.
### System configuration
 NVDA installed
instaled the beta version of nvda.
#### NVDA version:
nvda 2021.3 beta 2.
#### Windows version:
Windows 11 21H2 (x64) build 22000.348
#### Name and version of other software in use when reproducing the issue:

#### Other information about your system:

### Other questions
#### Does the issue still occur after restarting your computer?
yes it does.
#### Have you tried any other versions of NVDA? If so, please report their behaviors.
yes. it happens on every version of nvda.
#### If NVDA add-ons are disabled, is your problem still occurring?
yes.
#### Does the issue still occur after you run the COM Registration Fixing Tool in NVDA's tools menu?
yes.
[nvda.log](https://github.com/nvaccess/nvda/files/7618575/nvda.log)



Discussion:
if you need anything, please let me know.
thanks
Hi, resolved via Windows App Essentials add-on – this issue is caused by the fact that emoji search field gets focused when emoji panel opens, with NVDA using the arrow keys for character navigation purposes instead of passing it onto the emoji panel. Thanks.


according to my tests, if the add-on
NVDAExtensionGlobalPlugin-
is installed nvda continues to speak in white.
which is a shame, I really like this add-on.


Another question, if the option to
Auto focus mode when focus changes
is unchecked, when walking with the arrow below in the list of emogis, nvda is announcing windows input experience for several times, making the use of this window unfeasible.
For this second point, if a solution were possible, it would be very interesting. 
Hi, just to make sure: what happens if you enable Windows App Essentials add-on? If that solves the problem, then it gives me a good reason to write a pull request this week. Thanks.


if I enable the add-on
Windows App Essentials;
everything works though:
even with the complement
Windows App Essentials;
installed, if the add-on
NVDAExtensionGlobalPlugin-
is installed will not work, the blank ad continues.
it is also necessary that the option
Auto focus mode when focus changes
is checked.
if it is unchecked, an ad of windows input experience is constantly informed when walking with the arrow below, making the use of the window unfeasible.
in short, currently for everything to work it is necessary
install the addon
Windows App Essentials;
uninstall the addon
NVDAExtensionGlobalPlugin-
check the option
Auto focus mode when focus changes 
Cc @paulber19 for information regarding the "NVDAExtensionGlobalPlugin:" add-on. Maybe a patched function that is not up-to-date in the add-on.



Resolving patch:
diff --git a/source/appModules/textinputhost.py b/source/appModules/textinputhost.py
--- a/source/appModules/textinputhost.py
+++ b/source/appModules/textinputhost.py
@@ -1,10 +1,9 @@
-# App module for Text Input Host (formerly Composable Shell (CShell) input panel)
 # A part of NonVisual Desktop Access (NVDA)
-# Copyright (C) 2019 NV Access Limited, Joseph Lee
+# Copyright (C) 2019-2021 NV Access Limited, Joseph Lee
 # This file is covered by the GNU General Public License.
 # See the file COPYING for more details.
 
-"""App module for Windows 10 Modern Keyboard aka new touch keyboard panel.
+"""App module for Windows 10/11 Modern Keyboard aka new touch keyboard panel.
 This is for 20H1 text input host window."""
 
 # Flake8/F403: alias of Composable Shell modern keyboard app module.
diff --git a/source/appModules/windowsinternal_composableshell_experiences_textinput_inputapp.py b/source/appModules/windowsinternal_composableshell_experiences_textinput_inputapp.py
--- a/source/appModules/windowsinternal_composableshell_experiences_textinput_inputapp.py
+++ b/source/appModules/windowsinternal_composableshell_experiences_textinput_inputapp.py
@@ -3,9 +3,11 @@
 # This file is covered by the GNU General Public License.
 # See the file COPYING for more details.
 
-"""App module for Windows 10 Modern Keyboard aka new touch keyboard panel.
-The chief feature is allowing NVDA to announce selected emoji when using the keyboard to search for and select one.
-Other features include announcing candidates for misspellings if suggestions for hardware keyboard is selected, and managing cloud clipboard paste.
+"""App module for Windows 10/11 Modern Keyboard aka new touch keyboard panel.
+The chief feature is allowing NVDA to announce selected emoji
+when using the keyboard to search for and select one.
+Other features include reporting candidates for misspellings if suggestions for hardware keyboard is selected,
+and managing cloud clipboard paste.
 This is applicable on Windows 10 Fall Creators Update and later."""
 
 import appModuleHandler
@@ -18,7 +20,7 @@
 import winVersion
 import controlTypes
 from NVDAObjects.UIA import UIA
-from NVDAObjects.behaviors import CandidateItem as CandidateItemBehavior
+from NVDAObjects.behaviors import CandidateItem as CandidateItemBehavior, EditableTextWithAutoSelectDetection
 
 
 class ImeCandidateUI(UIA):
@@ -114,15 +116,18 @@ def event_UIA_elementSelected(self, obj, nextHandler):
 		# Therefore pass these events straight on.
 		if isinstance(obj, ImeCandidateItem):
 			return nextHandler()
-		# #7273: When this is fired on categories, the first emoji from the new category is selected but not announced.
+		# #7273: When this is fired on categories,
+		# the first emoji from the new category is selected but not announced.
 		# Therefore, move the navigator object to that item if possible.
 		# However, in recent builds, name change event is also fired.
 		# For consistent experience, report the new category first by traversing through controls.
-		# #8189: do not announce candidates list itself (not items), as this is repeated each time candidate items are selected.
+		# #8189: do not announce candidates list itself (not items),
+		# as this is repeated each time candidate items are selected.
 		if obj.UIAElement.cachedAutomationID == "CandidateList":
 			return
 		speech.cancelSpeech()
-		# Sometimes, due to bad tree traversal or wrong item getting selected, something other than the selected item sees this event.
+		# Sometimes, due to bad tree traversal or wrong item getting selected,
+		# something other than the selected item sees this event.
 		# In build 18262, emoji panel may open to People group and skin tone modifier gets selected.
 		if obj.parent.UIAAutomationId == "SkinTonePanelModifier_ListView":
 			# But this will point to nothing if emoji search results are not people.
@@ -131,9 +136,14 @@ def event_UIA_elementSelected(self, obj, nextHandler):
 			else:
 				obj = obj.parent.parent.firstChild
 		candidate = obj
-		if obj and obj.UIAElement.cachedClassName == "ListViewItem" and obj.parent and isinstance(obj.parent, UIA) and obj.parent.UIAElement.cachedAutomationID != "TEMPLATE_PART_ClipboardItemsList":
+		if (
+			obj and obj.UIAElement.cachedClassName == "ListViewItem"
+			and obj.parent and isinstance(obj.parent, UIA)
+			and obj.parent.UIAElement.cachedAutomationID != "TEMPLATE_PART_ClipboardItemsList"
+		):
 			# The difference between emoji panel and suggestions list is absence of categories/emoji separation.
-			# Turns out automation ID for the container is different, observed in build 17666 when opening clipboard copy history.
+			# Turns out automation ID for the container is different,
+			# observed in build 17666 when opening clipboard copy history.
 			candidate = obj.parent.previous
 			if candidate is not None:
 				# Emoji categories list.
@@ -150,7 +160,8 @@ def event_UIA_elementSelected(self, obj, nextHandler):
 			# Cache selected item.
 			self._recentlySelected = obj.name
 		else:
-			# Translators: presented when there is no emoji when searching for one in Windows 10 Fall Creators Update and later.
+			# Translators: presented when there is no emoji when searching for one
+			# in Windows 10 Fall Creators Update and later.
 			ui.message(_("No emoji"))
 		nextHandler()
 
@@ -169,7 +180,8 @@ def event_UIA_window_windowOpen(self, obj, nextHandler):
 
 		# Make sure to announce most recently used emoji first in post-1709 builds.
 		# Fake the announcement by locating 'most recently used" category and calling selected event on this.
-		# However, in build 17666 and later, child count is the same for both emoji panel and hardware keyboard candidates list.
+		# However, in build 17666 and later, child count is the same
+		# for both emoji panel and hardware keyboard candidates list.
 		# Thankfully first child automation ID's are different for each modern input technology.
 		# However this event is raised when the input panel closes.
 		if firstChild is None:
@@ -213,7 +225,8 @@ def event_UIA_window_windowOpen(self, obj, nextHandler):
 			eventHandler.queueEvent("UIA_elementSelected", emojiItem)
 		# Clipboard history.
 		# Move to clipboard list so element selected event can pick it up.
-		# #9103: if clipboard is empty, a status message is displayed instead, and luckily it is located where clipboard data items can be found.
+		# #9103: if clipboard is empty, a status message is displayed instead,
+		# and luckily it is located where clipboard data items can be found.
 		elif childAutomationId == "TEMPLATE_PART_ClipboardTitleBar":
 			# Under some cases, clipboard tip text isn't shown on screen,
 			# causing clipboard history title to be announced instead of most recently copied item.
@@ -237,14 +250,19 @@ def event_nameChange(self, obj, nextHandler):
 		elif isinstance(obj, ImeCandidateUI):
 			return nextHandler()
 
-		# On some systems, touch keyboard keys keeps firing name change event.
-		# In build 17704, whenever skin tones are selected, name change is fired by emoji entries (GridViewItem).
-		if ((obj.UIAElement.cachedClassName in ("CRootKey", "GridViewItem"))
-		# Just ignore useless clipboard status.
-		# Also top emoji search result must be announced for better user experience.
-		or (obj.UIAElement.cachedAutomationID in ("TEMPLATE_PART_ClipboardItemsList", "TEMPLATE_PART_Search_TextBlock"))
-		# And no, emoji entries should not be announced here.
-		or (self._recentlySelected is not None and self._recentlySelected in obj.name)):
+		if (
+			# On some systems, touch keyboard keys keeps firing name change event.
+			# In build 17704, whenever skin tones are selected, name change is fired by emoji entries (GridViewItem).
+			(obj.UIAElement.cachedClassName in ("CRootKey", "GridViewItem"))
+			# Just ignore useless clipboard status.
+			# Also top emoji search result must be announced for better user experience.
+			or (obj.UIAElement.cachedAutomationID in (
+				"TEMPLATE_PART_ClipboardItemsList",
+				"TEMPLATE_PART_Search_TextBlock"
+			))
+			# And no, emoji entries should not be announced here.
+			or (self._recentlySelected is not None and self._recentlySelected in obj.name)
+		):
 			return
 		# The word "blank" is kept announced, so suppress this on build 17666 and later.
 		if winVersion.getWinVer() > winVersion.WIN10_1803:
@@ -252,13 +270,27 @@ def event_nameChange(self, obj, nextHandler):
 			# return immediately when element selected event on clipboard item was fired just prior to this.
 			# In some cases, parent will be None, as seen when emoji panel is closed in build 18267.
 			try:
-				if obj.UIAElement.cachedAutomationID == "TEMPLATE_PART_ClipboardItemIndex" or obj.parent.UIAElement.cachedAutomationID == "TEMPLATE_PART_ClipboardItemsList": return
+				if (
+					obj.UIAElement.cachedAutomationID == "TEMPLATE_PART_ClipboardItemIndex"
+					or obj.parent.UIAElement.cachedAutomationID == "TEMPLATE_PART_ClipboardItemsList"
+				):
+					return
 			except AttributeError:
 				return
-			if not self._emojiPanelJustOpened or obj.UIAElement.cachedAutomationID != "TEMPLATE_PART_ExpressionGroupedFullView": speech.cancelSpeech()
+			if (
+				not self._emojiPanelJustOpened
+				or obj.UIAElement.cachedAutomationID != "TEMPLATE_PART_ExpressionGroupedFullView"
+			):
+				speech.cancelSpeech()
 			self._emojiPanelJustOpened = False
 		# Don't forget to add "Microsoft Candidate UI" as something that should be suppressed.
-		if obj.UIAElement.cachedAutomationID not in ("TEMPLATE_PART_ExpressionFullViewItemsGrid", "TEMPLATE_PART_ClipboardItemIndex", "CandidateWindowControl"):
+		if (
+			obj.UIAElement.cachedAutomationID not in (
+				"TEMPLATE_PART_ExpressionFullViewItemsGrid",
+				"TEMPLATE_PART_ClipboardItemIndex",
+				"CandidateWindowControl"
+			)
+		):
 			ui.message(obj.name)
 		nextHandler()
 
@@ -280,3 +312,8 @@ def chooseNVDAObjectOverlayClasses(self, obj, clsList):
 				"IME_Prediction_Window"
 			):
 				clsList.insert(0, ImeCandidateUI)
+			# #13104: newer revisions of Windows 11 build 22000 moves focus to emoji search field.
+			# However this means NVDA's own edit field scripts will override emoji panel commands.
+			# Therefore remove text field movement commands so emoji panel commands can be used directly.
+			elif obj.UIAAutomationId == "Windows.Shell.InputApp.FloatingSuggestionUI.DelegationTextBox":
+				clsList.remove(EditableTextWithAutoSelectDetection)


Test patch: