Skip to content

Commit 67e14c1

Browse files
committed
WHAT: Add missing onBlur
WHY: * XXXXX HOW: * NOTHING TO SAY
1 parent e67941a commit 67e14c1

File tree

8 files changed

+25
-21
lines changed

8 files changed

+25
-21
lines changed

examples/TimePickerWrapper.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,11 @@ class TimePickerWrapper extends React.Component {
3737
meridiem
3838
} = options;
3939

40-
console.log(options);
4140
this.setState({ hour, minute, meridiem });
4241
}
4342

4443
onFocusChange(focused) {
44+
console.log(`onFocusChange: ${focused}`);
4545
this.setState({ focused });
4646
}
4747

examples/TimePickerWrapper2.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ class TimePickerWrapper extends React.Component {
4949
meridiem
5050
} = options;
5151

52-
console.log(options);
5352
this.setState({
5453
[section]: Object.assign({}, this.state[section], {
5554
hour, minute, meridiem

src/components/MaterialTheme/TwentyFourHoursMode.jsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,6 @@ class TwentyFourHoursMode extends React.PureComponent {
8282
}
8383

8484
handleTimeChange(time, autoMode = null) {
85-
console.log(`time: ${time}`);
86-
console.log(`autoMode: ${autoMode}`);
8785
const validateTime = parseInt(time, 10);
8886
const { step } = this.state;
8987
const auto = autoMode === null ? this.props.autoMode : autoMode;

src/components/OutsideClickHandler.jsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,10 @@ class OutsideClickHandler extends React.PureComponent {
4141
}
4242

4343
onOutsideClick(e) {
44-
console.log('onOutsideClick onOutsideClick onOutsideClick')
4544
const event = e || window.event;
4645
const mouseTarget = (typeof event.which !== 'undefined') ? event.which : event.button;
4746
const isDescendantOfRoot = ReactDOM.findDOMNode(this.childNode).contains(event.target);
4847

49-
console.log(`isDescendantOfRoot: ${isDescendantOfRoot}, mouseTarget: ${mouseTarget}`);
5048
if (!isDescendantOfRoot && mouseTarget === 1) {
5149
const { onOutsideClick } = this.props;
5250
onOutsideClick && onOutsideClick(event);

src/components/Picker/PickerPoint.jsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,6 @@ const PickerPoint = (props) => {
3232
style={inlineStyle}
3333
className={pointClass}
3434
onClick={() => {
35-
console.log('PickerPoint clicked');
36-
console.log(props);
3735
let relativeRotate = angle - (pointerRotate % 360);
3836
if (relativeRotate >= 180) {
3937
relativeRotate -= 360;

src/components/TimePicker.jsx

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -108,9 +108,9 @@ class TimePicker extends React.PureComponent {
108108
timeChanged: false
109109
};
110110

111+
this.onBlur = this.onBlur.bind(this);
111112
this.onFocus = this.onFocus.bind(this);
112113
this.timeData = this.timeData.bind(this);
113-
this.onClearFocus = this.onClearFocus.bind(this);
114114
this.handleTimeChange = this.handleTimeChange.bind(this);
115115
this.handleHourChange = this.handleHourChange.bind(this);
116116
this.handleMinuteChange = this.handleMinuteChange.bind(this);
@@ -132,11 +132,23 @@ class TimePicker extends React.PureComponent {
132132
}
133133

134134
onFocus() {
135-
this.setState({
136-
focused: true
137-
});
135+
const { focused } = this.state;
136+
if (!focused) {
137+
this.onFocusChange(!focused);
138+
}
139+
}
140+
141+
onBlur() {
142+
const { focused } = this.state;
143+
if (focused) {
144+
this.onFocusChange(!focused);
145+
}
146+
}
147+
148+
onFocusChange(focused) {
149+
this.setState({ focused });
138150
const { onFocusChange } = this.props;
139-
onFocusChange && onFocusChange(true);
151+
onFocusChange && onFocusChange(focused);
140152
}
141153

142154
timeData(timeChanged) {
@@ -224,10 +236,6 @@ class TimePicker extends React.PureComponent {
224236
return m && !!(m.match(/^am|pm/i)) ? localMessages[m.toLowerCase()] : m;
225237
}
226238

227-
onClearFocus() {
228-
this.setState({ focused: false });
229-
}
230-
231239
onTimeChanged(timeChanged) {
232240
this.setState({ timeChanged });
233241
}
@@ -271,7 +279,7 @@ class TimePicker extends React.PureComponent {
271279
handleHourAndMinuteChange(time) {
272280
this.onTimeChanged(true);
273281
const { onTimeChange, autoClose } = this.props;
274-
if (autoClose) this.onClearFocus();
282+
if (autoClose) this.onBlur();
275283
return onTimeChange && onTimeChange(time);
276284
}
277285

@@ -313,7 +321,7 @@ class TimePicker extends React.PureComponent {
313321
showTimezone={showTimezone}
314322
phrases={this.languageData}
315323
colorPalette={colorPalette}
316-
clearFocus={this.onClearFocus}
324+
clearFocus={this.onBlur}
317325
timeMode={parseInt(timeMode, 10)}
318326
onTimezoneChange={onTimezoneChange}
319327
minuteStep={parseInt(minuteStep, 10)}
@@ -366,7 +374,7 @@ class TimePicker extends React.PureComponent {
366374
)}
367375
<OutsideClickHandler
368376
focused={focused}
369-
onOutsideClick={this.onClearFocus}
377+
onOutsideClick={this.onBlur}
370378
closeOnOutsideClick={closeOnOutsideClick}
371379
>
372380
{this.renderDialPlate()}

stories/ClassicThemePicker.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ storiesOf('Classic Theme', module)
88
.addWithInfo('basic', () => (
99
<TimePickerWrapper theme="classic" />
1010
))
11+
.addWithInfo('with default time', () => (
12+
<TimePickerWrapper theme="classic" defaultTime="17:00" />
13+
))
1114
.addWithInfo('dark color', () => (
1215
<TimePickerWrapper theme="classic" colorPalette="dark" />
1316
))

test/components/TimePicker_func_spec.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ describe('TimePicker func', () => {
1616

1717
it('should clear focus', () => {
1818
const wrapper = shallow(<TimePicker />);
19-
wrapper.instance().onClearFocus();
19+
wrapper.instance().onBlur();
2020
expect(wrapper.state().focused).to.equal(false);
2121
});
2222

0 commit comments

Comments
 (0)