Skip to content

Commit

Permalink
Apply the same approach to web platforms
Browse files Browse the repository at this point in the history
  • Loading branch information
QichenZhu committed Dec 9, 2024
1 parent b8fdae8 commit f20c05d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
5 changes: 3 additions & 2 deletions src/components/TextInput/BaseTextInput/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ function BaseTextInput(
autoFocus = false,
disableKeyboard = false,
autoGrow = false,
autoGrowExtraSpace = 0,
autoGrowHeight = false,
maxAutoGrowHeight,
hideFocusedState = false,
Expand Down Expand Up @@ -257,7 +258,8 @@ function BaseTextInput(
const newTextInputContainerStyles: StyleProp<ViewStyle> = StyleSheet.flatten([
styles.textInputContainer,
textInputContainerStyles,
(autoGrow || !!contentWidth) && StyleUtils.getWidthStyle(textInputWidth),
!!contentWidth && StyleUtils.getWidthStyle(textInputWidth),
autoGrow && StyleUtils.getAutoGrowWidthInputContainerStyles(textInputWidth, autoGrowExtraSpace),
!hideFocusedState && isFocused && styles.borderColorFocus,
(!!hasError || !!errorText) && styles.borderColorDanger,
autoGrowHeight && {scrollPaddingTop: typeof maxAutoGrowHeight === 'number' ? 2 * maxAutoGrowHeight : undefined},
Expand Down Expand Up @@ -493,7 +495,6 @@ function BaseTextInput(
)}
{/*
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 or height of the input value given textStyle in this component.
This Text component is intentionally positioned out of the screen.
*/}
Expand Down
4 changes: 1 addition & 3 deletions src/components/TextInput/BaseTextInput/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,7 @@ type CustomBaseTextInputProps = {
*/
autoGrow?: boolean;

/**
* If autoGrow is enabled, this reserves extra space for incoming characters to prevent flickering on native platforms.
*/
/** If autoGrow is enabled, this reserves extra space for incoming characters to prevent flickering. */
autoGrowExtraSpace?: number;

/**
Expand Down

0 comments on commit f20c05d

Please sign in to comment.