-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Fix for: Editing workspace name to 1to3 characters adding extra line in the optional message when inviting users in Spanish #17878
Merged
Merged
Changes from 3 commits
Commits
Show all changes
30 commits
Select commit
Hold shift + click to select a range
2663cd8
Added autoGrowHeight feature
Ollyws 3996bfe
Added autoGrowHeight prop
Ollyws 63da719
Added paddingRight to baseTextInput
Ollyws d1e8606
Changed AND to ternary
Ollyws fb35aa7
Added autoGrowHeight to baseTextInputPropTypes
Ollyws 9c8cc25
Changed to set multiline true when autoGrowHeight
Ollyws 51a725d
Updated comment for onLayout
Ollyws 49e44c7
Removed multiline prop from TextInput
Ollyws b598295
Added isMultiline variable
Ollyws f5490c1
Simplified onLayout
Ollyws 8306310
Added AutoGrowHeightInput to stories
Ollyws 971dce9
Added layout const
Ollyws 208e9db
Only add zerowidth space if last char is linebreak
Ollyws a8f6a16
Changed props.multiline to isMultiline
Ollyws 094db19
Export AutoGrowHeightInput
Ollyws 5d1f2ce
Merge branch 'main' into issue-17202
Ollyws 7c380e7
Add autoGrowHeight prop to TextInput
Ollyws d4b545a
Moved MiniReportActionContextMenu to top of view
Ollyws 7082422
Revert move MiniReportActionContextMenu
Ollyws fc49ff6
Add scrollPadding for autoGrowHeight
Ollyws f1b6854
Merge branch 'main' into issue-17202
Ollyws 40aeb20
Added minHeight to autoGrowHeight textInput
Ollyws 3266612
Added getAutoGrowHeightInputStyle to StyleUtils
Ollyws 2344a77
Implemented getAutoGrowHeightInputStyle
Ollyws f125bd6
Added autoGrowHeightInputContainer
Ollyws 6c17fb7
Implemented autoGrowHeightInputContainer
Ollyws 4959935
remove scrollPaddingTop and add textInput height
Ollyws 4b4dab1
Added scrollPaddingTop to textInputContainer
Ollyws f58ea34
removed duplicate minHeight
Ollyws af4d0c7
Removed zero width space
Ollyws 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
This file contains 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 |
---|---|---|
@@ -1,7 +1,7 @@ | ||
import _ from 'underscore'; | ||
import React, {Component} from 'react'; | ||
import { | ||
Animated, View, TouchableWithoutFeedback, AppState, Keyboard, | ||
Animated, View, TouchableWithoutFeedback, AppState, Keyboard, StyleSheet, | ||
} from 'react-native'; | ||
import Str from 'expensify-common/lib/str'; | ||
import RNTextInput from '../RNTextInput'; | ||
|
@@ -218,21 +218,26 @@ class BaseTextInput extends Component { | |
!this.props.hideFocusedState && this.state.isFocused && styles.borderColorFocus, | ||
(this.props.hasError || this.props.errorText) && styles.borderColorDanger, | ||
], (finalStyles, s) => ({...finalStyles, ...s}), {}); | ||
const maxHeight = StyleSheet.flatten(this.props.containerStyles).maxHeight; | ||
const autoGrowHeight = this.props.autoGrowHeight && this.props.multiline; | ||
|
||
return ( | ||
<> | ||
<View> | ||
<View | ||
style={[ | ||
(autoGrowHeight && {height: this.state.textInputHeight >= maxHeight ? maxHeight : this.state.textInputHeight}), | ||
!this.props.multiline && styles.componentHeightLarge, | ||
...this.props.containerStyles, | ||
]} | ||
> | ||
<TouchableWithoutFeedback onPress={this.onPress} focusable={false}> | ||
<View | ||
|
||
// When multiline is not supplied, calculating textinput height using onLayout | ||
onLayout={event => !this.props.multiline && this.setState({height: event.nativeEvent.layout.height})} | ||
// When autoGrowHeight is true calculate textinput width or when multiline | ||
// is not supplied calculate textinput height, using onLayout. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These comments are not so clear. Could you please update it ? |
||
onLayout={event => (autoGrowHeight && this.setState({width: event.nativeEvent.layout.width})) | ||
|| (!this.props.multiline && this.setState({height: event.nativeEvent.layout.height}))} | ||
style={[ | ||
textInputContainerStyles, | ||
|
||
|
@@ -301,6 +306,9 @@ class BaseTextInput extends Component { | |
// Explicitly remove `lineHeight` from single line inputs so that long text doesn't disappear | ||
// once it exceeds the input space (See https://github.com/Expensify/App/issues/13802) | ||
!this.props.multiline && {height: this.state.height, lineHeight: undefined}, | ||
|
||
// Stop scrollbar flashing when breaking lines with autoGrowHeight enabled. | ||
autoGrowHeight && this.state.textInputHeight <= maxHeight ? styles.overflowHidden : styles.overflowAuto, | ||
]} | ||
multiline={this.props.multiline} | ||
maxLength={this.props.maxLength} | ||
|
@@ -351,17 +359,19 @@ class BaseTextInput extends Component { | |
{/* | ||
Text input component doesn't support auto grow by default. | ||
We're using a hidden text input to achieve that. | ||
This text view is used to calculate width of the input value given textStyle in this component. | ||
This text view is used to calculate width or height of the input value given textStyle in this component. | ||
This Text component is intentionally positioned out of the screen. | ||
*/} | ||
{this.props.autoGrow && ( | ||
{(this.props.autoGrow || autoGrowHeight) && ( | ||
|
||
// Add +2 to width so that the first digit of amount do not cut off on mWeb - https://github.com/Expensify/App/issues/8158. | ||
<Text | ||
style={[...this.props.inputStyle, styles.hiddenElementOutsideOfWindow, styles.visibilityHidden]} | ||
onLayout={e => this.setState({textInputWidth: e.nativeEvent.layout.width + 2})} | ||
style={[...this.props.inputStyle, autoGrowHeight && {maxWidth: this.state.width}, styles.hiddenElementOutsideOfWindow, styles.visibilityHidden]} | ||
Ollyws marked this conversation as resolved.
Show resolved
Hide resolved
|
||
onLayout={e => this.setState({textInputWidth: e.nativeEvent.layout.width + 2, textInputHeight: e.nativeEvent.layout.height})} | ||
> | ||
{this.state.value || this.props.placeholder} | ||
{/* We are appending a zero width space (\u200B) here as the browser will remove a trailing newline that doesn't | ||
have any characters after it. This allows linebreaks to work properly on web when the user presses enter. */} | ||
{`${this.state.value}${autoGrowHeight ? '\u200B' : ''}` || this.props.placeholder} | ||
</Text> | ||
)} | ||
</> | ||
|
This file contains 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
This file contains 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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
autoGrowHeight
should be added tobaseTextInputPropTypes
. Also I think we should remove this line and usethis.props.autoGrowHeight
directly, and for the input's propmultiline
, we can update it to :There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So when
autoGrowHeight
is applied ,multiline
should automatically set totrue