Skip to content

Commit c3d24d4

Browse files
SaraVieiraCompuIves
authored andcommitted
Tag focus (codesandbox#1388)
**What kind of change does this PR introduce?** Fixes loose focus on keydown <!-- You can also link to an open issue here --> **What is the current behavior?** Removed focus on keypress **What is the new behavior?** Works now closes codesandbox#1385
1 parent 665294f commit c3d24d4

File tree

2 files changed

+12
-14
lines changed
  • packages/app/src/app

2 files changed

+12
-14
lines changed

packages/app/src/app/components/EditableTags/index.js

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@ import React, { Fragment } from 'react';
22
import { createGlobalStyle } from 'styled-components';
33
import TagsInput from 'react-tagsinput';
44

5-
export default function(color) {
6-
const GlobalStyle = createGlobalStyle`
5+
const GlobalStyle = createGlobalStyle`
76
.react-tagsinput {
87
display: flex;
98
flex-wrap: row;
@@ -19,7 +18,7 @@ export default function(color) {
1918
margin: 0.2rem;
2019
font-size: 13px;
2120
padding: 0.3em 0.5em;
22-
background-color: ${color()};
21+
background-color: ${props => props.color};
2322
color: white;
2423
font-weight: 500;
2524
border-radius: 4px;
@@ -43,7 +42,7 @@ export default function(color) {
4342
width: 80px;
4443
4544
&:focus {
46-
border-color: ${color.clearer(0.3)()};
45+
border-color: ${props => props.color.clearer(0.3)};
4746
}
4847
}
4948
@@ -58,10 +57,9 @@ export default function(color) {
5857
}
5958
`;
6059

61-
return props => (
62-
<Fragment>
63-
<GlobalStyle />
64-
<TagsInput {...props} />
65-
</Fragment>
66-
);
67-
}
60+
export default props => (
61+
<Fragment>
62+
<GlobalStyle color={props.template.color} />
63+
<TagsInput {...props} />
64+
</Fragment>
65+
);

packages/app/src/app/pages/Sandbox/Editor/Workspace/Project/index.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import UserWithAvatar from 'app/components/UserWithAvatar';
1313
import Stats from 'app/pages/common/Stats';
1414
import PrivacyStatus from 'app/components/PrivacyStatus';
1515
import GithubBadge from 'common/components/GithubBadge';
16-
import createEditableTags from 'app/components/EditableTags';
16+
import EditableTags from 'app/components/EditableTags';
1717
import Tags from 'common/components/Tags';
1818
import Switch from 'common/components/Switch';
1919
import Tooltip from 'common/components/Tooltip';
@@ -102,7 +102,6 @@ class Project extends React.Component {
102102

103103
const template = getTemplateDefinition(sandbox.template);
104104

105-
const EditableTags = createEditableTags(template.color);
106105
return (
107106
<div style={{ marginBottom: '1rem' }}>
108107
<Item style={{ marginTop: '.5rem' }}>
@@ -217,17 +216,18 @@ class Project extends React.Component {
217216
<StatsContainer>
218217
<Stats sandbox={sandbox} />
219218
</StatsContainer>
220-
221219
<Item>
222220
{editable ? (
223221
<EditableTags
222+
template={template}
224223
value={sandbox.tags.toJS()}
225224
onChange={this.changeTags}
226225
onChangeInput={value => {
227226
signals.workspace.tagChanged({
228227
tagName: value,
229228
});
230229
}}
230+
maxTags={5}
231231
inputValue={store.workspace.tags.tagName}
232232
renderInput={this.renderInput}
233233
onlyUnique

0 commit comments

Comments
 (0)