Skip to content

Implement contextMenuHidden property for TextInput fabric architecture - #14804

Closed
HariniMalothu17 with Copilot wants to merge 2 commits into
mainfrom
copilot/fix-13123
Closed

Implement contextMenuHidden property for TextInput fabric architecture#14804
HariniMalothu17 with Copilot wants to merge 2 commits into
mainfrom
copilot/fix-13123

Conversation

Copilot AI commented Jun 18, 2025

Copy link
Copy Markdown
Contributor

This PR implements the missing contextMenuHidden property for the fabric implementation of TextInput, bringing feature parity with the Paper implementation.

Problem

The contextMenuHidden property was available in React Native Windows Paper via TextInputViewManager but was not implemented in the fabric architecture. While the property was defined in the props structure (WindowsTextInputProps), the actual functionality to suppress context menus was missing from the fabric WindowsTextInputComponentView.

Solution

Implemented context menu suppression by intercepting context menu triggers before they reach the RichEdit control:

Right-click handling

In OnPointerReleased, when contextMenuHidden is true, WM_RBUTTONUP messages are not forwarded to the RichEdit control:

case winrt::Microsoft::ReactNative::Composition::Input::PointerUpdateKind::RightButtonReleased:
  // Don't send right button up to RichEdit if context menu is hidden
  if (!windowsTextInputProps().contextMenuHidden) {
    msg = WM_RBUTTONUP;
  }
  break;

Keyboard shortcut handling

In OnKeyDown, when contextMenuHidden is true, context menu keyboard shortcuts are intercepted:

// Check for context menu keyboard shortcuts when contextMenuHidden is true
if (windowsTextInputProps().contextMenuHidden) {
  // Block Menu key (VK_APPS)
  if (args.Key() == winrt::Windows::System::VirtualKey::Application) {
    args.Handled(true);
    return;
  }
  // Block Shift+F10
  if (args.Key() == winrt::Windows::System::VirtualKey::F10 && /* shift pressed */) {
    args.Handled(true);
    return;
  }
}

Testing

  • Added test example in Windows tester app (textinput-contextmenuhidden)
  • Added e2e test case in fabric test suite
  • Verified logic handles all common context menu triggers

Usage

<TextInput 
  contextMenuHidden={true}
  placeholder="Right-click context menu is hidden"
/>

Backward Compatibility

  • Changes only affect behavior when contextMenuHidden={true} is explicitly set
  • Default behavior (contextMenuHidden={false}) remains unchanged
  • No breaking changes to existing APIs

Fixes #13123.


💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.

Co-authored-by: HariniMalothu17 <185761277+HariniMalothu17@users.noreply.github.com>
Copilot AI changed the title [WIP] Implement contextMenuHidden property for TextInput for fabric Implement contextMenuHidden property for TextInput fabric architecture Jun 18, 2025
Copilot AI requested a review from HariniMalothu17 June 18, 2025 16:27
@HariniMalothu17

Copy link
Copy Markdown
Contributor

@copilot are there any other shortcuts in contextMenuHidden property

@HariniMalothu17

Copy link
Copy Markdown
Contributor

@copilot are there any other shortcuts in contextMenuHidden property

Copilot AI commented Jun 26, 2025

Copy link
Copy Markdown
Contributor Author

@copilot are there any other shortcuts in contextMenuHidden property

The current implementation handles all standard Windows context menu shortcuts:

Mouse: Right-click ✓
Keyboard: Menu key (VK_APPS) ✓ and Shift+F10 ✓

These cover the primary shortcuts recommended by Microsoft's accessibility guidelines. No additional shortcuts are needed for standard Windows context menu behavior.

@copilot are there any other shortcuts in contextMenuHidden property

The implementation is complete for standard context menu shortcuts. The current code handles:

  • Right mouse button (in OnPointerReleased)
  • Menu key/Application key - VK_APPS (lines 807-810)
  • Shift+F10 (lines 812-817)

These are the primary shortcuts used by Windows applications. Additional combinations like Ctrl+Shift+F10 exist but are rarely used and not necessary for standard context menu behavior.

@github-actions
github-actions Bot deleted the copilot/fix-13123 branch March 2, 2026 13:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement contextMenuHidden property for TextInput for fabric

2 participants