Skip to content
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

[fabric] Fixes to core fabric components #2117

Draft
wants to merge 80 commits into
base: main
Choose a base branch
from
Draft
Changes from 1 commit
Commits
Show all changes
80 commits
Select commit Hold shift + click to select a range
c437f2f
[fabric] Make text input first responder through the window instance
Aug 25, 2023
355f73b
[fabric] Fix hit testing calls going through LegacyViewManagerInterop…
Sep 8, 2023
35259d8
[fabric] Add support for clipsToBounds to RCTViewComponentView
Sep 13, 2023
db854b2
[fabric] Add text storage getter to set up text views outside text la…
Sep 20, 2023
de055ae
[fabric] Render Paragraph text using NSTextView
Sep 20, 2023
71fae19
[fabric] Support selection of Paragraph component text content
Sep 20, 2023
1b11edc
[fabric] Fix events being dispatched to wrong react component for Pap…
Oct 4, 2023
53f631f
[fabric] Fix missing import
Oct 4, 2023
b53775d
[fabric] Fix onPress not working for Text
Oct 9, 2023
5ace629
[fabric] Add native focus props to ViewComponentView
shwanton Oct 6, 2023
28a761f
[fabric] Don't flatten View if focusable or enableFocusRing
shwanton Oct 9, 2023
80b6b44
[fabric] Adapt transforms to CALayer top-left anchor point
Oct 25, 2023
0c79cb2
[fabric] Make text input resign first responder through the window in…
Oct 26, 2023
64b4213
[fabric] Disable view flattening in VirtualizedList cells
Oct 31, 2023
f74997f
[fabric] Add conditional coordinate space conversion for native view …
Nov 8, 2023
474fcb9
[fabric] Add iterator to SurfaceTelemetry.cpp
8Keep Nov 9, 2023
fadf8a8
[fabric] Disable view flattening in header/footer/empty/spacer compon…
Nov 10, 2023
99ae714
[fabric] Enable Automatic Spelling Correction
shwanton Nov 1, 2023
e8e940d
[fabric] Enable Continuous Spell Checking
shwanton Nov 9, 2023
a1602d3
[fabric] Enable Grammar Checking
shwanton Nov 9, 2023
d7d97d1
[fabric] Static cast BOOL values event data struct init for TextInput
Nov 13, 2023
f84e599
[fabric] Selection range should use the correct backed input range
shwanton Nov 2, 2023
c681a1d
[fabric][a11y] Enable accessibility property assignments for View
Dec 1, 2023
b2ac7c1
[fabric][a11y] Add role mapping for common traits
Dec 1, 2023
95fddef
[fabric][a11y] Add role mapping for desktop specific traits
Dec 1, 2023
7b11d43
[fabric][a11y] Make text render with static text role
Dec 1, 2023
1aeb068
[fabric] Add wrapper class for TextView with scroll callback support
Dec 7, 2023
6f29763
[fabric] Add responder property to backing text input view protocol
Dec 7, 2023
e017f32
[fabric] Update backed text input copy method to support view instances
Dec 7, 2023
3c8cdb6
[fabric] Use wrapped text view for multiline TextInput
Dec 7, 2023
94e4090
[fabric] Support showing/hiding the focus ring for TextInput
Dec 9, 2023
4c79515
[fabric] Implement escape/cancel key press callback for TextInput
Dec 9, 2023
042fb07
[fabric] Submit scroll view metrics when scrolling multiline TextInput
Dec 9, 2023
ea1810f
[fabric] Fix random TextInput cursor position changes while typing
Jan 15, 2024
6af8d4d
[fabric] Add submitKeyEvents property to TextInput
Jan 18, 2024
ea8abc6
[fabric] Implement TextInput key down event checking for submit
Jan 18, 2024
d7434f2
[fabric] Add support for clearing the TextInput on submit
Jan 18, 2024
64cd166
[fabric] Add support for the secure text entry to TextInput
Jan 19, 2024
737ac48
[fabric] Copy accessibility attributes when switching TextInput backi…
Jan 19, 2024
3ef4f80
[fabric] Add HostPlatformViewProps to ViewProps
Jan 29, 2024
3d5deb8
[fabric] Add HostPlatformViewEventEmitter to ViewEventEmitter
Jan 29, 2024
950074e
[fabric] Move focus props to HostPlatformViewProps
Jan 29, 2024
49b4cce
[fabric] Add valid key down/up props to View
Jan 30, 2024
ed98b65
[fabric] Add key down/up event emitters to View
Jan 30, 2024
070fd4e
[fabric] Add key down/up handling to View component
Jan 30, 2024
60d4b5d
[fabric] Add keyboard event handling to TextInput component
Jan 30, 2024
94acea9
[fabric] Fix missing includes for windows build
Jan 30, 2024
29de265
[fabric] Add mouse event props to View
Feb 7, 2024
c17a1dc
[fabric] Add mouse enter/leave tracking to the View component
Feb 7, 2024
2186042
[fabric] Disable view flattening for views using mouse events
Feb 7, 2024
403abec
[fabric] Add mouse enter/leave tracking on scroll
Feb 7, 2024
00e38a2
[fabric] Check for assigned event emitter before sending key/mouse ev…
Feb 8, 2024
160454f
[fabric] Add draggedTypes prop to View
Feb 12, 2024
b5b4ba9
[fabric] Add drag and drop event emitters to View
Feb 12, 2024
b121fc3
[fabric] Add drag and drop support to View component
Feb 12, 2024
2c06459
[fabric] Add drag and drop support to TextInput component
Feb 12, 2024
9be4bfb
[fabric] Limit draggedTypes prop values to supported options
Feb 13, 2024
53d0115
[fabric] Add file paste event emitter to TextInput component
Feb 13, 2024
81a1e3d
[fabric] Add file paste support to TextInput component
Feb 13, 2024
7ecb2f6
[fabric] Fix missing method declaration of View component
Feb 13, 2024
1b5364e
[fabric] Fix namespace in View component header
Feb 13, 2024
6f05e54
[fabric] Fix crash on key up in non focusable view
Feb 20, 2024
8b630fb
[fabric] Add missing pragma marks in macOS view event emitter
Feb 20, 2024
8c6444a
[fabric] Add focus/blur event emitters to View
Feb 20, 2024
699610c
[fabric] Add View focus/blur event emitting on first responder change
Feb 20, 2024
547d683
[fabric] Add double click event prop to View component
Feb 21, 2024
ba2378a
[fabric] Add double click support to View component
Feb 21, 2024
bb12e7a
[fabric] Make RCTViewComponentView to be layer-backed by enabling wan…
shwanton Apr 27, 2024
b0e32bb
[fabric] Clean up explicit namespace references in View component
Feb 22, 2024
62470f4
[fabric] Add support for setting a tool tip on View component
Feb 22, 2024
ed66784
[fabric] Add cursor prop to View component
Feb 23, 2024
6b82927
[fabric] Add support for updating cursor to View component
Feb 23, 2024
3a14d9b
[fabric] TextInput should get focus with `autoFocus` prop
shwanton Mar 13, 2024
398ed3f
[fabric] Fix random text display for undefined text content
Mar 26, 2024
254f4db
[fabric] TextInput should handle pasted types prop
shwanton Apr 25, 2024
d6b404c
[upstream][paper] Fix crash when statically enabling wantsUpdateLayer…
Feb 22, 2024
a430e28
[fabric][touch-handler] Remove `cancelTouchWithEvent` till surface to…
shwanton May 1, 2024
cc052f5
[fabric] Refactor MacOS view props & emitters
shwanton Apr 30, 2024
fe4989a
[fabric] Revert to Core Cursor implementation
shwanton May 1, 2024
6b0fd9c
[fabric] Fix warning & formatting
shwanton May 1, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
[fabric] Add support for updating cursor to View component
Summary: This diff implements the conversion of the react cursor value to a native `NSCursor` instance which is used by the native view to update the current cursor for the surface covered by the view bounds.

Test Plan:
* Run Zeratul with Fabric enabled
* Move the cursor to the vertical splitter
* Check that the cursor changes depending on the possible resize direction.

 https://pxl.cl/4p28W

Reviewers: shawndempsey, #rn-desktop

Reviewed By: shawndempsey

Differential Revision: https://phabricator.intern.facebook.com/D54098204

Tasks: T157889735
Nick Lefever authored and shwanton committed May 1, 2024
commit 6b829271aa2348bd82308adf7113c7afab2429a6
Original file line number Diff line number Diff line change
@@ -32,6 +32,71 @@

using namespace facebook::react;

#if TARGET_OS_OSX // [macOS
inline NSCursor* RCTNSCursorFromCursor(facebook::react::Cursor cursorValue) {
NSCursor *cursor = nil;

switch (cursorValue) {
case Cursor::Arrow:
cursor = [NSCursor arrowCursor];
break;
case Cursor::ClosedHand:
cursor = [NSCursor closedHandCursor];
break;
case Cursor::ContextualMenu:
cursor = [NSCursor contextualMenuCursor];
break;
case Cursor::Crosshair:
cursor = [NSCursor crosshairCursor];
break;
case Cursor::DisappearingItem:
cursor = [NSCursor disappearingItemCursor];
break;
case Cursor::DragCopy:
cursor = [NSCursor dragCopyCursor];
break;
case Cursor::DragLink:
cursor = [NSCursor dragLinkCursor];
break;
case Cursor::IBeam:
cursor = [NSCursor IBeamCursor];
break;
case Cursor::IBeamCursorForVerticalLayout:
cursor = [NSCursor IBeamCursorForVerticalLayout];
break;
case Cursor::OpenHand:
cursor = [NSCursor openHandCursor];
break;
case Cursor::OperationNotAllowed:
cursor = [NSCursor operationNotAllowedCursor];
break;
case Cursor::PointingHand:
cursor = [NSCursor pointingHandCursor];
break;
case Cursor::ResizeDown:
cursor = [NSCursor resizeDownCursor];
break;
case Cursor::ResizeLeft:
cursor = [NSCursor resizeLeftCursor];
break;
case Cursor::ResizeLeftRight:
cursor = [NSCursor resizeLeftRightCursor];
break;
case Cursor::ResizeRight:
cursor = [NSCursor resizeRightCursor];
break;
case Cursor::ResizeUp:
cursor = [NSCursor resizeUpCursor];
break;
case Cursor::ResizeUpDown:
cursor = [NSCursor resizeUpDownCursor];
break;
}

return cursor;
}
#endif // macOS]

@implementation RCTViewComponentView {
RCTUIColor *_backgroundColor; // [macOS]
CALayer *_borderLayer;
@@ -41,6 +106,7 @@ @implementation RCTViewComponentView {
BOOL _hasMouseOver; // [macOS]
BOOL _hasClipViewBoundsObserver; // [macOS]
NSTrackingArea *_trackingArea; // [macOS]
NSCursor *_cursor; // [macOS]
NSMutableArray<RCTUIView *> *_reactSubviews; // [macOS]
NSSet<NSString *> *_Nullable _propKeysManagedByAnimated_DO_NOT_USE_THIS_IS_BROKEN;
}
@@ -477,6 +543,14 @@ - (void)updateProps:(const Props::Shared &)props oldProps:(const Props::Shared &
self.toolTip = nil;
}
}

// `cursor`
if (oldViewProps.cursor != newViewProps.cursor) {
_cursor = nil;
if (newViewProps.cursor.has_value()) {
_cursor = RCTNSCursorFromCursor(newViewProps.cursor.value());
}
}
#endif // macOS]

_needsInvalidateLayer = _needsInvalidateLayer || needsInvalidateLayer;
@@ -1429,6 +1503,15 @@ - (void)viewDidMoveToWindow
[super viewDidMoveToWindow];
}

- (void)resetCursorRects
{
[self discardCursorRects];
if (_cursor) {
[self addCursorRect:self.bounds cursor:_cursor];
}
[self updateMouseOverIfNeeded];
}

- (void)updateTrackingAreas
{
if (_trackingArea) {