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

Fix for: Editing workspace name to 1to3 characters adding extra line in the optional message when inviting users in Spanish #17878

Merged
merged 30 commits into from
May 5, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
2663cd8
Added autoGrowHeight feature
Ollyws Apr 24, 2023
3996bfe
Added autoGrowHeight prop
Ollyws Apr 24, 2023
63da719
Added paddingRight to baseTextInput
Ollyws Apr 24, 2023
d1e8606
Changed AND to ternary
Ollyws Apr 24, 2023
fb35aa7
Added autoGrowHeight to baseTextInputPropTypes
Ollyws Apr 24, 2023
9c8cc25
Changed to set multiline true when autoGrowHeight
Ollyws Apr 24, 2023
51a725d
Updated comment for onLayout
Ollyws Apr 24, 2023
49e44c7
Removed multiline prop from TextInput
Ollyws Apr 24, 2023
b598295
Added isMultiline variable
Ollyws Apr 24, 2023
f5490c1
Simplified onLayout
Ollyws Apr 24, 2023
8306310
Added AutoGrowHeightInput to stories
Ollyws Apr 25, 2023
971dce9
Added layout const
Ollyws Apr 25, 2023
208e9db
Only add zerowidth space if last char is linebreak
Ollyws Apr 25, 2023
a8f6a16
Changed props.multiline to isMultiline
Ollyws Apr 26, 2023
094db19
Export AutoGrowHeightInput
Ollyws Apr 26, 2023
5d1f2ce
Merge branch 'main' into issue-17202
Ollyws May 1, 2023
7c380e7
Add autoGrowHeight prop to TextInput
Ollyws May 1, 2023
d4b545a
Moved MiniReportActionContextMenu to top of view
Ollyws May 2, 2023
7082422
Revert move MiniReportActionContextMenu
Ollyws May 2, 2023
fc49ff6
Add scrollPadding for autoGrowHeight
Ollyws May 3, 2023
f1b6854
Merge branch 'main' into issue-17202
Ollyws May 3, 2023
40aeb20
Added minHeight to autoGrowHeight textInput
Ollyws May 3, 2023
3266612
Added getAutoGrowHeightInputStyle to StyleUtils
Ollyws May 3, 2023
2344a77
Implemented getAutoGrowHeightInputStyle
Ollyws May 3, 2023
f125bd6
Added autoGrowHeightInputContainer
Ollyws May 3, 2023
6c17fb7
Implemented autoGrowHeightInputContainer
Ollyws May 3, 2023
4959935
remove scrollPaddingTop and add textInput height
Ollyws May 4, 2023
4b4dab1
Added scrollPaddingTop to textInputContainer
Ollyws May 4, 2023
f58ea34
removed duplicate minHeight
Ollyws May 4, 2023
af4d0c7
Removed zero width space
Ollyws May 4, 2023
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
26 changes: 18 additions & 8 deletions src/components/TextInput/BaseTextInput.js
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';
Expand Down Expand Up @@ -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;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

autoGrowHeight should be added to baseTextInputPropTypes. Also I think we should remove this line and use this.props.autoGrowHeight directly, and for the input's prop multiline, we can update it to :

multiline={this.props.multiline || this.props.autoGrowHeight}

Copy link
Contributor

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 to true


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.
Copy link
Contributor

Choose a reason for hiding this comment

The 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,

Expand Down Expand Up @@ -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}
Expand Down Expand Up @@ -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>
)}
</>
Expand Down
2 changes: 1 addition & 1 deletion src/pages/workspace/WorkspaceInvitePage.js
Original file line number Diff line number Diff line change
Expand Up @@ -342,8 +342,8 @@ class WorkspaceInvitePage extends React.Component {
<TextInput
label={this.props.translate('workspace.invite.personalMessagePrompt')}
autoCompleteType="off"
autoGrowHeight
autoCorrect={false}
numberOfLines={4}
textAlignVertical="top"
multiline
Ollyws marked this conversation as resolved.
Show resolved Hide resolved
containerStyles={[styles.workspaceInviteWelcome]}
Expand Down
3 changes: 2 additions & 1 deletion src/styles/styles.js
Original file line number Diff line number Diff line change
Expand Up @@ -843,6 +843,7 @@ const styles = {
paddingTop: 23,
paddingBottom: 8,
paddingLeft: 0,
paddingRight: 0,
borderWidth: 0,
},

Expand Down Expand Up @@ -2603,7 +2604,7 @@ const styles = {
},

workspaceInviteWelcome: {
minHeight: 115,
maxHeight: 115,
Ollyws marked this conversation as resolved.
Show resolved Hide resolved
},

peopleRow: {
Expand Down