Skip to content

Fix Incubator TextField placeholder's disabled color #2003

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

Merged
merged 3 commits into from
Apr 25, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 2 additions & 2 deletions src/incubator/TextField/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import React, {useMemo} from 'react';
import {isEmpty, trim, omit} from 'lodash';
import {asBaseComponent, forwardRef} from '../../commons/new';
import View from '../../components/view';
import {Colors} from '../../style';
import {useMeasure} from '../../hooks';
import {TextFieldProps, InternalTextFieldProps, ValidationMessagePosition, FieldContextType, TextFieldMethods} from './types';
import {shouldHidePlaceholder} from './Presenter';
Expand Down Expand Up @@ -44,6 +43,7 @@ const TextField = (props: InternalTextFieldProps) => {
floatingPlaceholderColor,
floatingPlaceholderStyle,
floatOnFocus,
placeholderTextColor,
hint,
// Label
label,
Expand Down Expand Up @@ -128,7 +128,7 @@ const TextField = (props: InternalTextFieldProps) => {
)}
{children || (
<Input
placeholderTextColor={hidePlaceholder ? 'transparent' : Colors.$textNeutral}
placeholderTextColor={hidePlaceholder ? 'transparent' : placeholderTextColor}
Copy link
Collaborator

Choose a reason for hiding this comment

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

technically you're replacing the default value with undefined, no?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

No, I am changing the default for a non-floating placeholder from a string (set here to: Colors.$textNeutral) to an object (set in default.ts->placeholderTextColorByState); and this way I can set the disabled type to look like it's disabled: Colors.$textDisabled

{...others}
style={[typographyStyle, colorStyle, others.style]}
onFocus={onFocus}
Expand Down
8 changes: 8 additions & 0 deletions src/incubator/TextField/presets/default.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@ const colorByState = {
disabled: Colors.$textDisabled
};

const placeholderTextColorByState = {
default: Colors.$textNeutral,
error: Colors.$textNeutral,
focus: Colors.$textNeutral,
disabled: Colors.$textDisabled
};

const styles = StyleSheet.create({
field: {
borderBottomWidth: 1,
Expand All @@ -25,6 +32,7 @@ export default {
enableErrors: true,
validateOnBlur: true,
floatingPlaceholderColor: colorByState,
placeholderTextColor: placeholderTextColorByState,
labelColor: colorByState,
fieldStyle: styles.field,
style: styles.input,
Expand Down