-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Styled input loose focus on change #540
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
Comments
Could you post a more detailed reproduction please? |
Hi there, i have the same issue. import React from 'react';
import styled from 'styled-components';
import Button from './Button';
export default function SearchBar(props) {
const CustomInput = styled.input`
font-size: 1em;
text-align: left;
border: 1px solid #EFEFEF;
padding: 0.5em;
width: 100%;
border-radius: 10px;
`;
const SearchBarWrapper = styled.div`
display: flex;
align-items: stretch;
width: 280px;
animation: ${props.animation}
`
const PrimaryColumn = styled.div`
flex: 2
`
const SecondaryColumn = styled.div`
flex: 1
`
return (
<SearchBarWrapper>
<PrimaryColumn>
<CustomInput
type="text"
placeholder="City"
onChange={props.onChange}
value={props.value}
/>
</PrimaryColumn>
<SecondaryColumn>
<Button label="GO" primary/>
</SecondaryColumn>
</SearchBarWrapper>
);
} |
@theocar If you move the styled components out of the SearchBar Component it should work. import React from 'react';
import styled from 'styled-components';
import Button from './Button';
const CustomInput = styled.input`
font-size: 1em;
text-align: left;
border: 1px solid #EFEFEF;
padding: 0.5em;
width: 100%;
border-radius: 10px;
`;
const SearchBarWrapper = styled.div`
display: flex;
align-items: stretch;
width: 280px;
animation: ${props.animation}
`
const PrimaryColumn = styled.div`
flex: 2
`
const SecondaryColumn = styled.div`
flex: 1
`
export default function SearchBar(props) {
return (
<SearchBarWrapper>
<PrimaryColumn>
<CustomInput
type="text"
placeholder="City"
onChange={props.onChange}
value={props.value}
/>
</PrimaryColumn>
<SecondaryColumn>
<Button label="GO" primary/>
</SecondaryColumn>
</SearchBarWrapper>
);
} |
8 tasks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Version
1.4.3
Steps to reproduce
MaterialFormGroup = styled.div` ... `;
Expected Behavior
the input only is refreshed on typing (using onChange)
Actual Behavior
When looking at the real-DOM, the form is refreshed, and so, the input loose focus at each key press
The text was updated successfully, but these errors were encountered: