Skip to content

Commit df1a254

Browse files
author
Ives van Hoorne
committed
Focus on input when clicking
1 parent bd6768b commit df1a254

File tree

1 file changed

+22
-7
lines changed
  • src/app/pages/SandboxView/Editor/Content/View/subviews/Preview

1 file changed

+22
-7
lines changed

src/app/pages/SandboxView/Editor/Content/View/subviews/Preview/AddressBar.js

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,13 @@ const Container = styled.div`
77
vertical-align: middle;
88
`;
99

10-
const Input = styled.input`
11-
padding: 0.2rem 1rem;
12-
color: black;
13-
width: 100%;
14-
box-sizing: border-box;
10+
const InputContainer = styled.div`
11+
input {
12+
padding: 0.2rem 1rem;
13+
color: black;
14+
width: 100%;
15+
box-sizing: border-box;
16+
}
1517
`;
1618

1719
const Slash = styled.span`
@@ -48,12 +50,25 @@ export default class extends React.PureComponent {
4850
}
4951
}
5052

53+
focus = () => {
54+
if (this.input) {
55+
this.input.focus();
56+
}
57+
}
58+
5159
render() {
5260
const { url = '' } = this.props;
5361
return (
54-
<Container>
62+
<Container onClick={this.focus}>
5563
<Slash>/</Slash>
56-
<Input onChange={this.onChange} onKeyDown={this.handleKeyDown} value={url} />
64+
<InputContainer>
65+
<input
66+
ref={(e) => { this.input = e; }}
67+
onChange={this.onChange}
68+
onKeyDown={this.handleKeyDown}
69+
value={url}
70+
/>
71+
</InputContainer>
5772
</Container>
5873
);
5974
}

0 commit comments

Comments
 (0)