Skip to content

Commit 4de9874

Browse files
committed
fix forms, drop unneeded deps
1 parent 5250d14 commit 4de9874

File tree

12 files changed

+45
-86
lines changed

12 files changed

+45
-86
lines changed

lib/components/Form/selectField.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ var __assign = (this && this.__assign) || Object.assign || function(t) {
1010
var React = require('react');
1111
var SelectField_1 = require('material-ui/SelectField');
1212
var selectField = function (_a, props) {
13-
var children = _a.children, floatingLabelText = _a.floatingLabelText;
13+
var children = _a.children, floatingLabelText = _a.floatingLabelText, id = _a.id;
1414
return (React.createElement(SelectField_1.default, __assign({value: props.value, floatingLabelText: floatingLabelText, errorText: props.touched && props.error}, props, {onChange: function (event, index, value) { return props.onChange(value); }}), children));
1515
};
1616
Object.defineProperty(exports, "__esModule", { value: true });

lib/components/Form/textField.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ var __assign = (this && this.__assign) || Object.assign || function(t) {
1010
var React = require('react');
1111
var TextField_1 = require('material-ui/TextField');
1212
var textField = function (_a, props) {
13-
var hintText = _a.hintText, floatingLabelText = _a.floatingLabelText, disabled = _a.disabled;
14-
return (React.createElement(TextField_1.default, __assign({className: 'native-key-bindings', hintText: hintText, floatingLabelText: floatingLabelText, disabled: disabled, errorText: props.touched && props.error}, props)));
13+
var hintText = _a.hintText, floatingLabelText = _a.floatingLabelText, disabled = _a.disabled, id = _a.id;
14+
return (React.createElement(TextField_1.default, __assign({id: id, className: 'native-key-bindings', hintText: hintText, floatingLabelText: floatingLabelText, disabled: disabled || false, errorText: props.touched && props.error}, props)));
1515
};
1616
Object.defineProperty(exports, "__esModule", { value: true });
1717
exports.default = textField;

lib/components/TutorialConfig/index.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,12 @@ var TutorialConfig = (function (_super) {
5151
TopPanel_1.topElement.toggle(false);
5252
document.getElementsByTagName('input')[0].focus();
5353
};
54+
TutorialConfig.prototype.shouldComponentUpdate = function () {
55+
if (document.activeElement &&
56+
typeof document.activeElement.value === 'string') {
57+
return false;
58+
}
59+
};
5460
TutorialConfig.prototype.onSubmit = function (values) {
5561
var name = values.name, language = values.language, runner = values.runner;
5662
this.props.save(Object.assign({}, this.props.packageJson, {
@@ -65,16 +71,18 @@ var TutorialConfig = (function (_super) {
6571
return (React.createElement(Card_1.Card, {style: styles.card},
6672
React.createElement(Card_1.CardHeader, {title: 'Tutorial Configuration'}),
6773
React.createElement("form", {onSubmit: handleSubmit(this.onSubmit.bind(this))},
68-
React.createElement(redux_form_1.Field, {name: 'name', component: textField_1.default.bind(null, {
74+
React.createElement(redux_form_1.Field, {id: 'name', name: 'name', component: textField_1.default.bind(null, {
6975
hintText: 'coderoad-tutorial-name',
7076
})}),
7177
React.createElement(redux_form_1.Field, {name: 'language', component: selectField_1.default.bind(null, {
7278
children: languageItems_1.default(),
7379
floatingLabelText: 'language',
80+
id: 'language',
7481
})}),
7582
React.createElement(redux_form_1.Field, {name: 'runner', component: selectField_1.default.bind(null, {
7683
children: runnerItems_1.default('JS'),
7784
floatingLabelText: 'Test Runner',
85+
id: 'runner',
7886
})}),
7987
React.createElement(RaisedButton_1.default, {type: 'submit', style: styles.button, label: 'Save', primary: true, disabled: invalid}),
8088
React.createElement(RaisedButton_1.default, {style: styles.button, label: 'Continue', secondary: true, disabled: invalid, onTouchTap: this.props.routeToPage.bind(this)}))));

lib/components/TutorialInfo/index.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,13 @@ var TutorialInfo = (function (_super) {
4646
};
4747
TutorialInfo.prototype.componentDidMount = function () {
4848
TopPanel_1.topElement.toggle(false);
49+
document.getElementsByTagName('input')[0].focus();
50+
};
51+
TutorialInfo.prototype.shouldComponentUpdate = function () {
52+
if (document.activeElement &&
53+
typeof document.activeElement.value === 'string') {
54+
return false;
55+
}
4956
};
5057
TutorialInfo.prototype.onSubmit = function (values) {
5158
var description = values.description, version = values.version, keywords = values.keywords;

lib/components/common/Markdown.js

Lines changed: 0 additions & 31 deletions
This file was deleted.

package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,9 @@
2525
"dependencies": {
2626
"atom-plugin-command-line": "1.0.2",
2727
"coderoad-cli": "0.6.0",
28-
"core-coderoad": "0.3.0",
28+
"core-coderoad": "0.4.0",
2929
"highlights": "1.3.1",
3030
"lodash.debounce": "^4.0.6",
31-
"marked": "0.3.5",
3231
"material-ui": "0.15.0",
3332
"node-file-exists": "1.1.0",
3433
"react": "15.1.0",

src/components/Form/selectField.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import * as React from 'react';
22
import SelectField from 'material-ui/SelectField';
33

4-
const selectField = ({children, floatingLabelText}, props) => (
4+
const selectField = ({children, floatingLabelText, id}, props) => (
55
<SelectField
66
value={props.value}
77
floatingLabelText={floatingLabelText}

src/components/Form/textField.tsx

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,15 @@ import * as React from 'react';
22
import TextField from 'material-ui/TextField';
33

44
const textField = ({
5-
hintText, floatingLabelText, disabled
5+
hintText, floatingLabelText, disabled, id
66
}, props) => (
77
<TextField
8+
id={id}
89
className='native-key-bindings'
910
hintText={hintText}
1011
floatingLabelText={floatingLabelText}
11-
disabled={disabled}
12-
errorText={
13-
props.touched && props.error
14-
}
12+
disabled={disabled || false}
13+
errorText={props.touched && props.error}
1514
{...props}
1615
/>
1716
);

src/components/TutorialConfig/index.tsx

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,13 @@ class TutorialConfig extends React.Component <{
5555
// focus first element
5656
document.getElementsByTagName('input')[0].focus();
5757
}
58+
shouldComponentUpdate() {
59+
// hack to prevent lost focus on component update
60+
if (document.activeElement &&
61+
typeof document.activeElement.value === 'string') {
62+
return false;
63+
}
64+
}
5865
onSubmit(values) {
5966
const {name, language, runner} = values;
6067
this.props.save(Object.assign(
@@ -78,6 +85,7 @@ class TutorialConfig extends React.Component <{
7885
<form onSubmit={handleSubmit(this.onSubmit.bind(this))}>
7986

8087
<Field
88+
id='name'
8189
name='name'
8290
component={textField.bind(null, {
8391
hintText: 'coderoad-tutorial-name',
@@ -89,6 +97,7 @@ class TutorialConfig extends React.Component <{
8997
component={selectField.bind(null, {
9098
children: languageItems(),
9199
floatingLabelText: 'language',
100+
id: 'language',
92101
})}
93102
/>
94103

@@ -97,6 +106,7 @@ class TutorialConfig extends React.Component <{
97106
component={selectField.bind(null, {
98107
children: runnerItems('JS'),
99108
floatingLabelText: 'Test Runner',
109+
id: 'runner',
100110
})}
101111
/>
102112

@@ -123,5 +133,5 @@ class TutorialConfig extends React.Component <{
123133

124134
export default reduxForm({
125135
form: 'tutorialConfig',
126-
validate,
136+
validate,
127137
})(TutorialConfig);

src/components/TutorialInfo/index.tsx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,15 @@ class TutorialInfo extends React.Component<{
4040
}
4141
componentDidMount() {
4242
topElement.toggle(false);
43+
// focus first element
44+
document.getElementsByTagName('input')[0].focus();
45+
}
46+
shouldComponentUpdate() {
47+
// hack to prevent lost focus on component update
48+
if (document.activeElement &&
49+
typeof document.activeElement.value === 'string') {
50+
return false;
51+
}
4352
}
4453
onSubmit(values) {
4554
const {description, version, keywords} = values;

0 commit comments

Comments
 (0)