Skip to content

Commit

Permalink
feat: redirect import url on pressing enter (codesandbox#2954)
Browse files Browse the repository at this point in the history
  • Loading branch information
jyash97 authored and CompuIves committed Nov 1, 2019
1 parent a426049 commit efd1bd6
Showing 1 changed file with 10 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 54,15 @@ export const GitHubImport = () => {
}
}, []);

const handleKey = useCallback(
({ key }) => {
if (key === 'Enter' && !error) {
window.location.href = gitHubToSandboxUrl(url);
}
},
[error, url]
);

return (
<Section style={{ flex: 6 }}>
<ImportHeader>
Expand All @@ -76,6 85,7 @@ export const GitHubImport = () => {
placeholder="GitHub Repository URL..."
onChange={updateUrl}
value={url}
onKeyDown={handleKey}
/>

{transformedUrl ? (
Expand Down

0 comments on commit efd1bd6

Please sign in to comment.