Skip to content

Commit 8a1a4e5

Browse files
authored
Merge pull request #4942 from GeekyAnts/fix/textarea-value
Fix/textarea minor issues
2 parents 08dbe67 + bf7778d commit 8a1a4e5

File tree

4 files changed

+21
-11
lines changed

4 files changed

+21
-11
lines changed

example/storybook/stories/components/primitives/TextArea/value.tsx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,12 @@ import { TextArea, Box } from 'native-base';
33

44
export const Example = () => {
55
const [textAreaValue, setTextAreaValue] = useState('Value Controlled');
6-
const demoValueControlledTextArea = (e: any) => {
7-
setTextAreaValue(e.currentTarget.value);
8-
};
96
return (
107
<Box alignItems="center" w="100%">
118
<TextArea
129
value={textAreaValue}
13-
onChange={demoValueControlledTextArea}
10+
onChange={(e: any) => setTextAreaValue(e.currentTarget.value)} // for web
11+
onChangeText={(text: any) => setTextAreaValue(text)} // for android and ios
1412
w="75%"
1513
maxW="300"
1614
/>

src/components/primitives/TextArea/index.tsx

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,20 +19,34 @@ export interface ITextAreaProps
1919
}
2020

2121
const TextArea = (
22-
{ wrapperRef, isDisabled, isInvalid, isReadOnly, ...props }: ITextAreaProps,
22+
{
23+
wrapperRef,
24+
isDisabled,
25+
isInvalid,
26+
isReadOnly,
27+
isFocused: isFocusedProp,
28+
isHovered: isHoveredProp,
29+
...props
30+
}: ITextAreaProps,
2331
ref: any
2432
) => {
2533
const _ref = React.useRef(null);
2634
const { isHovered } = useHover({}, _ref);
27-
const [isFocused, setIsFocused] = React.useState(false);
35+
const [isFocused, setIsFocused] = React.useState(isFocusedProp);
2836
const handleFocus = (focusState: boolean, callback: any) => {
2937
setIsFocused(focusState);
3038
callback();
3139
};
3240
const { totalLines, onFocus, onBlur, ...newProps } = usePropsResolution(
3341
'TextArea',
3442
props,
35-
{ isHovered, isDisabled, isFocused, isInvalid, isReadOnly },
43+
{
44+
isHovered: isHoveredProp || isHovered,
45+
isDisabled,
46+
isFocused,
47+
isInvalid,
48+
isReadOnly,
49+
},
3650
{ extendTheme: ['Input'] }
3751
);
3852
//TODO: refactor for responsive prop

src/theme/components/input.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ const baseStyle = (props: any) => {
2727
bg: 'transparent',
2828
flex: 1,
2929
w: '100%',
30+
h: '100%',
3031
},
3132
_light: {
3233
placeholderTextColor: 'text.400',

src/theme/components/textarea.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
1-
import { Platform } from 'react-native';
2-
31
const baseStyle = {
42
multiline: true,
53
p: '2',
6-
totalLines: 4,
7-
h: Platform.select({ ios: 20 }),
84
textAlignVertical: 'top',
5+
h: '20',
96
};
107

118
export default {

0 commit comments

Comments
 (0)