floatingLabel HOC issues
See original GitHub issue"react": "
"react-native": "0.50.3",
"native-base": "^2.3.7",
Hello there. I am using redux-form and styled-components, and I have to apply 2 HOCS (one for <Field> from redux-form, and the second one from styled-components). And seems that floating labels don’t like that.
Expected behaviour
Using HOC inside of <Item floatingLabel>
(such as styled-components, or redux-form text input wrapper) should still work. This is the case only when using floatingLabel
prop.
Currently I am unable to change TextInput’s color in any way. Label’s color changing works only with style
attribute, however I would prefer to use styled-components (if I do that Label
is invisible)
** Everything is working as expected without floatingLabel prop**
Actual behaviour
- I am unable to change
TextInput
’s color by any way - The
<Label>
is invisible if styled-components are used
Steps to reproduce
- Create a wrapper for redux-form ready Input
import React from 'react';
import { Input as BaseInput } from 'native-base';
export function Input(props) {
const { input, ...rest } = props;
console.log(props);
return (
<BaseInput
{...rest}
onChangeText={input.onChange}
onBlur={input.onBlur}
onFocus={input.onFocus}
value={input.value}
/>
);
}
- Create another custom component which is the whole
<Item>
import React from 'react';
import { Item, Label } from 'native-base';
import { Input } from '@common';
import styled from 'styled-components';
const fieldLabelColor = 'rgba(255, 255, 255, .85)';
const FieldItem = styled(Item)`
margin-bottom: 12px;
margin-left: 0;
width: 100%;
`;
// This will render the label invisible
const FieldLabel = styled(Label)`
color: fieldLabelColor;
`;
// This won't have any effect and the text input will still be white
// The same thing would occur on passing style attribute to the Input
const FieldInput = styled(Input)`
color: #fff;
`;
// Using only styles on Label works fine, however Label as styled-component is invisible
// const labelStyles = {
// color: fieldLabelColor,
// };
export default function LoginStackFieldFloating({ label, ...rest }) {
return (
<FieldItem floatingLabel>
<FieldLabel>{label}</FieldLabel>
<FieldInput {...rest} />
</FieldItem>
);
}
- Use it in as component attribute of redux-form’s
<Field>
tag.
<Field component={LoginStackFieldFloating} name="something" />
Hopefully that makes sense. On Monday I’ll do more testing
Best regards.
Issue Analytics
- State:
- Created 6 years ago
- Comments:10 (5 by maintainers)
Top Results From Across the Web
Float labels are problematic - Adam Silver
Float labels are problematic · # 1. They're small and hard to read · # 2. They have poor contrast · # 3....
Read more >Are Float Labels Really That Problematic After All? | by MDS
The label may get cropped If the floating label is longer than the size of the field, it will be cut off by...
Read more >Querying basics | Prometheus
A vector may contain a mix of float samples and histogram samples. ... Label matchers that match empty label values also select all...
Read more >Floated Labels Still Suck
Like many accessibility problems on the web, floated labels can be attributed to multiple issues. Firstly, web designs are trendy, and when a...
Read more >Hour of Code Teacher Resources | Code.org
Animated astronaut and animal characters floating around an illustration of the earth ... ethical issues and how AI can be used to address...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@ppozniak true
@ppozniak Either keep the issue open if you need help Or close it, if you are planning to implement this sometime later