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

RN InputItem control styles modify Input color is invalid, see the source code is forced to cover the default style #1471

Closed
SturdyCat opened this issue Jun 20, 2017 · 3 comments
Assignees

Comments

@SturdyCat
Copy link

SturdyCat commented Jun 20, 2017

Version

1.3.1

Environment

windows10,chrome 60,react-native 0.44.2

Reproduction link

https://mobile.ant.design

Steps to reproduce

import InputItemStyle from 'antd-mobile/lib/input-item/style'
const newStyle = {}
for (const key in InputItemStyle) {
  if (Object.prototype.hasOwnProperty.call(InputItemStyle, key)) {
    console.log({key})
    newStyle[key] = { ...StyleSheet.flatten(InputItemStyle[key]) }
    if (key === 'input') {
      newStyle[key].color = '#fff'
    }
  }
}
 <InputItem styles={StyleSheet.create(newStyle)} />

// Source content
const inputStyle = {
      color: error ? '#f50' : variables.color_text_base,
    };
...
<Input
          clearButtonMode={clear ? 'while-editing' : 'never'}
          underlineColorAndroid="transparent"
          {...restProps}
          {...valueProps}
          style={[styles.input, inputStyle]} // 这里 styles的自定义color样式被inputStyle强制覆盖成color_text_base
          keyboardType={keyboardType}
          onChange={(event) => this.onChange(event.nativeEvent.text)}
          secureTextEntry={type === 'password'}
          onBlur={this.onInputBlur}
          onFocus={this.onInputFocus}
        />
...

What is expected?

Expecting a custom style should take precedence over the default style

What is actually happening?

The default style takes precedence over custom styles

@ant-design-bot
Copy link

It will be better to write your issue/comment in English, so more people can understand you.
And this means that more people can help you or benefit from your issue/comment.
See: ant-design/ant-design#4897

@SturdyCat SturdyCat changed the title RN InputItem 控件 styles 修改 Input color 无效看源码被默认样式强制覆盖 RN InputItem control styles modify Input color is invalid, see the source code is forced to cover the default style Jun 20, 2017
@warmhug warmhug added the RN label Jun 20, 2017
@silentcloud
Copy link
Contributor

@pingan1927 看哈这个之前这样设置的原因

@pingan1927
Copy link
Contributor

我今天仔细看看,好久没搞rn的了。

lixiaoyang1992 pushed a commit to lixiaoyang1992/ant-design-mobile that referenced this issue Apr 26, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants