Skip to content

Commit 3a2fe20

Browse files
committed
Use a fragment instead of returning an array for the TimeInput.
1 parent 1987334 commit 3a2fe20

File tree

2 files changed

+32
-36
lines changed

2 files changed

+32
-36
lines changed

src/TimeInput.js

+32-32
Original file line numberDiff line numberDiff line change
@@ -78,14 +78,14 @@ class TimeInput extends React.Component {
7878
autoOk,
7979
cancelLabel,
8080
classes,
81-
defaultValue, // eslint-disable-line
81+
defaultValue,
8282
disabled: disabledProp,
83-
initialTime, //eslint-disable-line
84-
placeholder, // eslint-disable-line
83+
initialTime,
84+
placeholder,
8585
mode,
8686
okLabel,
87-
onChange, // eslint-disable-line
88-
value: valueProp, // eslint-disable-line
87+
onChange,
88+
value: valueProp,
8989
...other
9090
} = this.props
9191

@@ -94,34 +94,34 @@ class TimeInput extends React.Component {
9494
const { muiFormControl } = this.context
9595
const disabled = disabledProp || (muiFormControl != null && muiFormControl.disabled)
9696

97-
return [
98-
<Input
99-
{...other}
100-
disabled={disabled}
101-
onClick={!disabled ? this.showDialog : null}
102-
value={this.getFormattedValue()}
103-
readOnly
104-
key='TimeInput-input'
105-
/>,
106-
<Dialog
107-
maxWidth='xs'
108-
open={this.state.open}
109-
key='TimeInput-dialog'
110-
onClose={this.handleCancel}
111-
>
112-
<TimePicker
113-
mode={mode}
114-
value={newValue}
115-
onChange={this.handleChange}
116-
onMinutesSelected={autoOk ? this.handleOk : null}
117-
classes={{ header: classes.header, body: classes.body }}
97+
return (
98+
<React.Fragment>
99+
<Input
100+
{...other}
101+
disabled={disabled}
102+
onClick={!disabled ? this.showDialog : null}
103+
value={this.getFormattedValue()}
104+
readOnly
118105
/>
119-
<DialogActions>
120-
<Button onClick={this.handleCancel} color='primary'>{cancelLabel}</Button>
121-
<Button onClick={this.handleOk} color='primary'>{okLabel}</Button>
122-
</DialogActions>
123-
</Dialog>
124-
]
106+
<Dialog
107+
maxWidth='xs'
108+
open={this.state.open}
109+
onClose={this.handleCancel}
110+
>
111+
<TimePicker
112+
mode={mode}
113+
value={newValue}
114+
onChange={this.handleChange}
115+
onMinutesSelected={autoOk ? this.handleOk : null}
116+
classes={{ header: classes.header, body: classes.body }}
117+
/>
118+
<DialogActions>
119+
<Button onClick={this.handleCancel} color='primary'>{cancelLabel}</Button>
120+
<Button onClick={this.handleOk} color='primary'>{okLabel}</Button>
121+
</DialogActions>
122+
</Dialog>
123+
</React.Fragment>
124+
)
125125
}
126126
}
127127

src/__snapshots__/TimeInput.spec.js.snap

-4
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ exports[`<TimeInput /> 12h matches the snapshot 1`] = `
2020
>
2121
<WithStyles(Input)
2222
disabled={false}
23-
key="TimeInput-input"
2423
onClick={[Function]}
2524
readOnly={true}
2625
value="1:37 pm"
@@ -70,7 +69,6 @@ exports[`<TimeInput /> 12h matches the snapshot 1`] = `
7069
</Input>
7170
</WithStyles(Input)>
7271
<WithStyles(Dialog)
73-
key="TimeInput-dialog"
7472
maxWidth="xs"
7573
onClose={[Function]}
7674
open={false}
@@ -182,7 +180,6 @@ exports[`<TimeInput /> 24h matches the snapshot 1`] = `
182180
>
183181
<WithStyles(Input)
184182
disabled={false}
185-
key="TimeInput-input"
186183
onClick={[Function]}
187184
readOnly={true}
188185
value="13:37"
@@ -232,7 +229,6 @@ exports[`<TimeInput /> 24h matches the snapshot 1`] = `
232229
</Input>
233230
</WithStyles(Input)>
234231
<WithStyles(Dialog)
235-
key="TimeInput-dialog"
236232
maxWidth="xs"
237233
onClose={[Function]}
238234
open={false}

0 commit comments

Comments
 (0)