Skip to content

Implement contextMenuHidden property for TextInput fabric architecture #14804

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

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

Copilot
Copy link
Contributor

@Copilot Copilot AI commented Jun 18, 2025

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.

@Copilot Copilot AI changed the title [WIP] Implement contextMenuHidden property for TextInput for fabric Implement contextMenuHidden property for TextInput fabric architecture Jun 18, 2025
Copilot finished work on behalf of HariniMalothu17 June 18, 2025 16:27
@Copilot Copilot AI requested a review from HariniMalothu17 June 18, 2025 16:27
@HariniMalothu17
Copy link
Contributor

@copilot are there any other shortcuts in contextMenuHidden property

@HariniMalothu17
Copy link
Contributor

@copilot are there any other shortcuts in contextMenuHidden property

Copy link
Contributor Author

Copilot AI commented Jun 26, 2025

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

Copilot finished work on behalf of HariniMalothu17 June 26, 2025 12:21
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