Skip to content

Commit

Permalink
fix(Field): 🐛 修复 valueStyle marginTop 被覆盖
Browse files Browse the repository at this point in the history
  • Loading branch information
onlyling committed Jul 16, 2024
1 parent 19561db commit 484bff5
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
8 changes: 8 additions & 0 deletions src/field/__fixtures__/text-input.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,14 @@ const BasicFieldTextInput: React.FC = () => {
value={text1}
onChange={setText1}
/>
<Field.TextInput
vertical
title="自定义 valueStyle"
valueStyle={{ marginTop: 16 }}
placeholder="请输入"
value={text1}
onChange={setText1}
/>
<Field.TextInput
type="textarea"
title="多行输入"
Expand Down
4 changes: 3 additions & 1 deletion src/field/field-password.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React, { memo } from 'react'
import { StyleSheet } from 'react-native'

import Cell from '../cell'
import PasswordInput from '../password-input'
Expand All @@ -25,6 +26,7 @@ const FieldPasswordInput: React.FC<FieldPasswordInputProps> = ({
}

const TOKENS = Theme.useThemeTokens()
const outerValueStyle = StyleSheet.flatten(cellProps.valueStyle || {})

return (
<Cell
Expand All @@ -33,7 +35,7 @@ const FieldPasswordInput: React.FC<FieldPasswordInputProps> = ({
cellProps.valueStyle,
cellProps.vertical
? {
marginTop: TOKENS.space_2,
marginTop: outerValueStyle.marginTop ?? TOKENS.space_2,
}
: null,
]}
Expand Down
4 changes: 3 additions & 1 deletion src/field/field-text-input.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React, { memo } from 'react'
import { StyleSheet } from 'react-native'

import Cell from '../cell'
import TextInput from '../text-input'
Expand Down Expand Up @@ -35,6 +36,7 @@ const FieldTextInput: React.FC<FieldTextInputProps> = ({
}

const TOKENS = Theme.useThemeTokens()
const outerValueStyle = StyleSheet.flatten(cellProps.valueStyle || {})

return (
<Cell
Expand All @@ -43,7 +45,7 @@ const FieldTextInput: React.FC<FieldTextInputProps> = ({
cellProps.valueStyle,
cellProps.vertical
? {
marginTop: TOKENS.space_2,
marginTop: outerValueStyle.marginTop ?? TOKENS.space_2,
}
: null,
]}
Expand Down

0 comments on commit 484bff5

Please sign in to comment.