Skip to content

Fix SHIFT+F10 keyboard shortcut for context menu in TextInput#15621

Open
Nitin-100 wants to merge 4 commits intomicrosoft:mainfrom
Nitin-100:nitin/fix-contextmenu-shiftf10
Open

Fix SHIFT+F10 keyboard shortcut for context menu in TextInput#15621
Nitin-100 wants to merge 4 commits intomicrosoft:mainfrom
Nitin-100:nitin/fix-contextmenu-shiftf10

Conversation

@Nitin-100
Copy link
Contributor

@Nitin-100 Nitin-100 commented Feb 3, 2026

Description

This PR fixes the SHIFT+F10 keyboard shortcut not working to show the context menu in TextInput components. Previously, pressing SHIFT+F10 would cause the application's File menu to blink instead of showing the TextInput context menu.

Type of Change

  • Bug fix (non-breaking change which fixes an issue)

Why

The SHIFT+F10 keyboard shortcut is a standard Windows accessibility feature for opening context menus. Users expect this shortcut to work in TextInput fields to access cut/copy/paste operations via keyboard.

Root Cause: Windows intercepts SHIFT+F10 at the system level. For ContentIsland hosting, the InputKeyboardSource.ContextMenuKey event wasn't being handled, so the event would fall through and activate the application's menu bar instead.

What

The following changes were made to fix the issue:

  1. Added ContextMenuRoutedEventArgs interface to Composition.Input.idl - New args class with Handled, Position, and IsKeyboardTriggered properties. This follows the same pattern as KeyRoutedEventArgs/CharacterReceivedRoutedEventArgs for easy future extension without breaking API changes.

  2. Added ContextMenu public event to ComponentView.idl - Allows native components to customize context menu behavior by subscribing to this event.

  3. Added OnContextMenu virtual method to ComponentView - Base class method that derived components can override to handle context menu requests.

  4. Added ContextMenuKey event handler in CompositionEventHandler - For ContentIsland hosting, this subscribes to InputKeyboardSource.ContextMenuKey and routes the event to the focused component's OnContextMenu method.

  5. Added WM_CONTEXTMENU handling in CompositionEventHandler::SendMessage - For HWND hosting (CompositionHwndHost), this routes the WM_CONTEXTMENU message to the focused component.

  6. Implemented OnContextMenu in WindowsTextInputComponentView - Calls ShowContextMenu() when the context menu is not hidden via props.

Screenshots

N/A - This is a keyboard interaction fix. Testing requires:

  1. Focus a TextInput component
  2. Press SHIFT+F10
  3. Context menu should appear with Cut/Copy/Paste options

Testing

Manual Testing Performed:

  • Verified SHIFT+F10 now shows the context menu in TextInput
  • Verified right-click context menu still works
  • Verified contextMenuHidden prop still prevents context menu from appearing

Test Scenarios:

  1. TextInput with focus + SHIFT+F10 → Context menu appears
  2. TextInput with contextMenuHidden={true} + SHIFT+F10 → No context menu
  3. Right-click on TextInput → Context menu appears

Changelog

Should this change be included in the release notes: yes

Fixed SHIFT+F10 keyboard shortcut not showing context menu in TextInput components.

@microsoft-github-policy-service microsoft-github-policy-service bot added the Needs: Author Feedback The issue/PR needs activity from its author (label drives bot activity) label Feb 3, 2026
@Nitin-100 Nitin-100 force-pushed the nitin/fix-contextmenu-shiftf10 branch from 8c0bda7 to 525ebd2 Compare February 3, 2026 19:01
@microsoft-github-policy-service microsoft-github-policy-service bot removed the Needs: Author Feedback The issue/PR needs activity from its author (label drives bot activity) label Feb 3, 2026
@Nitin-100 Nitin-100 force-pushed the nitin/fix-contextmenu-shiftf10 branch from 1153457 to b47add3 Compare February 5, 2026 05:51
- Add ContextMenuRoutedEventArgs interface to Composition.Input.idl

- Add ContextMenu event to ComponentView.idl

- Implement ContextMenuRoutedEventArgs in Composition.Input.h/cpp

- Add ContextMenu event handlers in ComponentView.h/cpp

- Subscribe to InputKeyboardSource.ContextMenuKey for ContentIsland hosting

- Handle WM_CONTEXTMENU for HWND hosting

- Implement OnContextMenu in WindowsTextInputComponentView
@Nitin-100 Nitin-100 force-pushed the nitin/fix-contextmenu-shiftf10 branch from b47add3 to 13de5f2 Compare February 5, 2026 05:55
args.Handled(true);
} else if (msg == WM_RBUTTONUP && windowsTextInputProps().contextMenuHidden) {
// Context menu is hidden, just mark as handled
args.Handled(true);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why mark it as handled if contextMenu is disabled? Why not allow apps to add their own right click behaviors?


void WindowsTextInputComponentView::OnContextMenu(
const winrt::Microsoft::ReactNative::Composition::Input::ContextMenuRoutedEventArgs &args) noexcept {
// Handle context menu event (generated for SHIFT+F10, Context Menu key, or right-click)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this event is generated on right-click, do we still need the WM_RBUTTONUP handlers? -- Or is this comment incorrect?

DOC_STRING("Used to handle key up events when this component is focused, or if a child component did not handle the key up")
event Windows.Foundation.EventHandler<Microsoft.ReactNative.Composition.Input.KeyRoutedEventArgs> KeyUp;
event Windows.Foundation.EventHandler<Microsoft.ReactNative.Composition.Input.CharacterReceivedRoutedEventArgs> CharacterReceived;
DOC_STRING("Used to handle context menu events (SHIFT+F10, Context Menu key, or right-click) when this component is focused")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given that this event is basically the InputKeyboardSource.ContextMenuKey event, which is a keyboard event. I dont think it would get fired on right-click as the comment here suggests. Also we should call the event ContextMenuKey to be consistent with the event it actually corresponds to.

DOC_STRING("Gets or sets whether the event was handled. Set to true to prevent default behavior.")
Boolean Handled { get; set; };
DOC_STRING("Gets the position where the context menu was requested, in local coordinates.")
Windows.Foundation.Point Position { get; };
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A keyboard event wouldn't really have a position associated with it. The upstream InputKeyboardSource.ContextMenuKey has no position associated with it.

UpdateCursor();
return 1;
}
case WM_CONTEXTMENU: {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We dont need to maintain the CompositionEventHandler::SendMessage code path any more. That was for driving a react root view without a ContentIsland. But that is no longer a supported scenario.

@microsoft-github-policy-service microsoft-github-policy-service bot added the Needs: Author Feedback The issue/PR needs activity from its author (label drives bot activity) label Feb 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Needs: Author Feedback The issue/PR needs activity from its author (label drives bot activity)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[React Native] [Amazon Kindle][60873901] Bug 2 - SHIFT F10 context menu keyboard shortcut does not work.

2 participants