Skip to content

Commit

Permalink
fix(iOS): Setting cursor on Text doesn't redbox
Browse files Browse the repository at this point in the history
  • Loading branch information
Saadnajmi committed May 13, 2024
1 parent 062205b commit 58b2bdb
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 28 deletions.
7 changes: 5 additions & 2 deletions packages/react-native/Libraries/Text/Text/RCTTextView.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,19 @@
* LICENSE file in the root directory of this source tree.
*/

#import <React/RCTComponent.h>

#import <UIKit/UIKit.h>

#import <React/RCTComponent.h>
#import <React/RCTCursor.h>

NS_ASSUME_NONNULL_BEGIN

@interface RCTTextView : UIView

@property (nonatomic, assign) BOOL selectable;

@property (nonatomic, assign) RCTCursor cursor;

- (void)setTextStorage:(NSTextStorage *)textStorage
contentFrame:(CGRect)contentFrame
descendantViews:(NSArray<UIView *> *)descendantViews;
Expand Down
51 changes: 25 additions & 26 deletions packages/rn-tester/js/examples/Cursor/CursorExample.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@ const styles = StyleSheet.create({
flexWrap: 'wrap',
gap: 10,
},
column: {
flexDirection: 'column',
flexWrap: 'wrap',
gap: 10,
},
centerContent: {
justifyContent: 'center',
alignItems: 'center',
Expand All @@ -54,39 +59,33 @@ const styles = StyleSheet.create({

function CursorExampleAuto() {
return (
<View style={styles.row}>
<View style={styles.box} />
<View style={styles.circle} />
<View style={styles.halfcircle} />
<View style={[styles.box, styles.solid]} />
<View style={[styles.circle, styles.solid]} />
<View style={[styles.halfcircle, styles.solid]} />
<View style={styles.column}>
<View style={styles.row}>
<View style={styles.box} />
<View style={styles.circle} />
<View style={styles.halfcircle} />
<View style={[styles.box, styles.solid]} />
<View style={[styles.circle, styles.solid]} />
<View style={[styles.halfcircle, styles.solid]} />
</View>
<Text>Some text</Text>
</View>
);
}

function CursorExamplePointer() {
return (
<View style={styles.row}>
<View style={[styles.box, styles.pointer]} />
<View style={[styles.circle, styles.pointer]} />
<View style={[styles.halfcircle, styles.pointer]} />
<View style={[styles.box, styles.solid, styles.pointer]} />
<View style={[styles.circle, styles.solid, styles.pointer]} />
<View style={[styles.halfcircle, styles.solid, styles.pointer]} />
</View>
);
}

function CursorExamplePointer() {
return (
<View style={styles.row}>
<View style={[styles.box, styles.pointer]} />
<View style={[styles.circle, styles.pointer]} />
<View style={[styles.halfcircle, styles.pointer]} />
<View style={[styles.box, styles.solid, styles.pointer]} />
<View style={[styles.circle, styles.solid, styles.pointer]} />
<View style={[styles.halfcircle, styles.solid, styles.pointer]} />
<View style={styles.column}>
<View style={styles.row}>
<View style={[styles.box, styles.pointer]} />
<View style={[styles.circle, styles.pointer]} />
<View style={[styles.halfcircle, styles.pointer]} />
<View style={[styles.box, styles.solid, styles.pointer]} />
<View style={[styles.circle, styles.solid, styles.pointer]} />
<View style={[styles.halfcircle, styles.solid, styles.pointer]} />
</View>
<Text style={styles.pointer}>Some text</Text>
</View>
);
}
Expand Down

0 comments on commit 58b2bdb

Please sign in to comment.