-
Notifications
You must be signed in to change notification settings - Fork 1.2k
[Fabric] Allow text components to have children #14438
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
Merged
Merged
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
960e20c
get images/views inline with text on fabric
TatianaKapos b326bd1
merge main
TatianaKapos 3d40ea6
add back in comments
TatianaKapos efc914c
Change files
TatianaKapos 0d45996
remove duplicate code
TatianaKapos f449e0c
add baseline for textinput
TatianaKapos 2b2e333
add checks for paper vs fabric
TatianaKapos 267ee72
try fixing image
TatianaKapos c59439d
add resize:none and tests
TatianaKapos 5b6fac7
fix override
TatianaKapos 4d65b48
comment out test
TatianaKapos 907e714
merge
TatianaKapos a984cf8
fix tests
TatianaKapos f0077cb
fix typo
TatianaKapos 4e33463
try to fix tests
TatianaKapos fab271c
Merge branch 'main' into tk-textInline
TatianaKapos efdd094
comment out text test
TatianaKapos 3d102fc
merge
TatianaKapos 83156ea
mark windows-specific changes
TatianaKapos File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
7 changes: 7 additions & 0 deletions
7
change/react-native-windows-02413c33-df01-48d8-beb1-092c80f1f706.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| { | ||
| "type": "prerelease", | ||
| "comment": "Allow text components to have children", | ||
| "packageName": "react-native-windows", | ||
| "email": "tatianakapos@microsoft.com", | ||
| "dependentChangeType": "patch" | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
229 changes: 229 additions & 0 deletions
229
packages/@react-native-windows/tester/src/js/components/TextInlineView.windows.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,229 @@ | ||
| /** | ||
| * Copyright (c) Meta Platforms, Inc. and affiliates. | ||
| * | ||
| * This source code is licensed under the MIT license found in the | ||
| * LICENSE file in the root directory of this source tree. | ||
| * | ||
| * @format | ||
| * @flow strict-local | ||
| */ | ||
|
|
||
| 'use strict'; | ||
|
|
||
| import RNTesterText from '../components/RNTesterText'; | ||
| import React from 'react'; | ||
| import {Image, TouchableHighlight, View} from 'react-native'; | ||
|
|
||
| function Basic(): React.Node { | ||
| return ( | ||
| <RNTesterText testID={'text-view'}> | ||
| This text contains an inline blue view{' '} | ||
| <View style={{width: 25, height: 25, backgroundColor: 'steelblue'}} /> and | ||
| an inline image <Image source={require('../assets/flux.png')} />. Neat, | ||
| huh? | ||
| </RNTesterText> | ||
| ); | ||
| } | ||
|
|
||
| function NestedTexts(): React.Node { | ||
| // [Windows] accessible = {true} is needed to find Views in e2etests | ||
| return ( | ||
| <View testID="text-nested-view" accessible={true}> | ||
| <RNTesterText>This is the first row</RNTesterText> | ||
| <RNTesterText> | ||
| <RNTesterText> | ||
| <RNTesterText>This is a nested text </RNTesterText> | ||
| <View style={{height: 20, width: 20, backgroundColor: 'red'}} /> | ||
| <RNTesterText> with a Red View</RNTesterText> | ||
| </RNTesterText> | ||
| </RNTesterText> | ||
| </View> | ||
| ); | ||
| } | ||
|
|
||
| function ClippedByText(): React.Node { | ||
| // [Windows] accessible = {true} is needed to find Views in e2etests | ||
| return ( | ||
| <View testID="text-view-images-clipped" accessible={true}> | ||
| {/* | ||
| * Inline View | ||
| **/} | ||
| <RNTesterText> | ||
| The{' '} | ||
| <RNTesterText style={{fontWeight: 'bold'}}>inline view</RNTesterText>{' '} | ||
| below is taller than its Text parent and should be clipped. | ||
| </RNTesterText> | ||
| <RNTesterText | ||
| style={{ | ||
| overflow: 'hidden', | ||
| width: 150, | ||
| height: 75, | ||
| backgroundColor: 'lightgrey', | ||
| }}> | ||
| This is an inline view | ||
| {/* Render a red border around the steelblue rectangle to make it clear how the inline view is being clipped */} | ||
| <View style={{width: 50, height: 100, backgroundColor: 'red'}}> | ||
| <View | ||
| style={{ | ||
| width: 48, | ||
| height: 98, | ||
| left: 1, | ||
| top: 1, | ||
| backgroundColor: 'steelblue', | ||
| }} | ||
| /> | ||
| </View> | ||
| </RNTesterText> | ||
|
|
||
| {/* | ||
| * Inline Image | ||
| **/} | ||
| <RNTesterText style={{marginTop: 10}}> | ||
| The{' '} | ||
| <RNTesterText style={{fontWeight: 'bold'}}>inline image</RNTesterText>{' '} | ||
| below is taller than its Text parent and should be clipped. | ||
| </RNTesterText> | ||
| <RNTesterText | ||
| style={{ | ||
| overflow: 'hidden', | ||
| width: 175, | ||
| height: 100, | ||
| backgroundColor: 'lightgrey', | ||
| }}> | ||
| This is an inline image | ||
| <Image | ||
| source={{ | ||
| uri: 'https://picsum.photos/100', | ||
| width: 50, | ||
| height: 100, | ||
| }} | ||
| style={{ | ||
| width: 50, | ||
| height: 100, | ||
| }} | ||
| /> | ||
| </RNTesterText> | ||
| </View> | ||
| ); | ||
| } | ||
|
|
||
| type ChangeSizeState = {| | ||
| width: number, | ||
| |}; | ||
|
|
||
| class ChangeImageSize extends React.Component<mixed, ChangeSizeState> { | ||
| state: ChangeSizeState = { | ||
| width: 50, | ||
| }; | ||
|
|
||
| render(): React.Node { | ||
| return ( | ||
| <View> | ||
| <TouchableHighlight | ||
| onPress={() => { | ||
| this.setState({width: this.state.width === 50 ? 100 : 50}); | ||
| }}> | ||
| <RNTesterText style={{fontSize: 15}}> | ||
| Change Image Width (width={this.state.width}) | ||
| </RNTesterText> | ||
| </TouchableHighlight> | ||
| <RNTesterText> | ||
| This is an | ||
| <Image | ||
| source={{ | ||
| uri: 'https://picsum.photos/50', | ||
| width: this.state.width, | ||
| height: 50, | ||
| }} | ||
| style={{ | ||
| width: this.state.width, | ||
| height: 50, | ||
| }} | ||
| /> | ||
| inline image | ||
| </RNTesterText> | ||
| </View> | ||
| ); | ||
| } | ||
| } | ||
|
|
||
| class ChangeViewSize extends React.Component<mixed, ChangeSizeState> { | ||
| state: ChangeSizeState = { | ||
| width: 50, | ||
| }; | ||
|
|
||
| render(): React.Node { | ||
| return ( | ||
| <View> | ||
| <TouchableHighlight | ||
| onPress={() => { | ||
| this.setState({width: this.state.width === 50 ? 100 : 50}); | ||
| }}> | ||
| <RNTesterText style={{fontSize: 15}}> | ||
| Change View Width (width={this.state.width}) | ||
| </RNTesterText> | ||
| </TouchableHighlight> | ||
| <RNTesterText> | ||
| This is an | ||
| <View | ||
| style={{ | ||
| width: this.state.width, | ||
| height: 50, | ||
| backgroundColor: 'steelblue', | ||
| }} | ||
| /> | ||
| inline view | ||
| </RNTesterText> | ||
| </View> | ||
| ); | ||
| } | ||
| } | ||
|
|
||
| class ChangeInnerViewSize extends React.Component<mixed, ChangeSizeState> { | ||
| state: ChangeSizeState = { | ||
| width: 50, | ||
| }; | ||
|
|
||
| render(): React.Node { | ||
| return ( | ||
| <View> | ||
| <TouchableHighlight | ||
| onPress={() => { | ||
| this.setState({width: this.state.width === 50 ? 100 : 50}); | ||
| }}> | ||
| {/* When updating `state.width`, it's important that the only thing that | ||
| changes is the width of the pink inline view. When we do this, we | ||
| demonstrate a bug in RN Android where the pink view doesn't get | ||
| rerendered and remains at its old size. If other things change | ||
| (e.g. we display `state.width` as text somewhere) it could circumvent | ||
| the bug and cause the pink view to be rerendered at its new size. */} | ||
| <RNTesterText style={{fontSize: 15}}> | ||
| Change Pink View Width | ||
| </RNTesterText> | ||
| </TouchableHighlight> | ||
| <RNTesterText> | ||
| This is an | ||
| <View style={{width: 125, height: 75, backgroundColor: 'steelblue'}}> | ||
| <View | ||
| style={{ | ||
| width: this.state.width, | ||
| height: 50, | ||
| backgroundColor: 'pink', | ||
| }} | ||
| /> | ||
| </View> | ||
| inline view | ||
| </RNTesterText> | ||
| </View> | ||
| ); | ||
| } | ||
| } | ||
|
|
||
| module.exports = { | ||
| Basic, | ||
| NestedTexts, | ||
| ClippedByText, | ||
| ChangeImageSize, | ||
| ChangeViewSize, | ||
| ChangeInnerViewSize, | ||
| }; | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.