Skip to content
This repository was archived by the owner on Oct 12, 2023. It is now read-only.

Commit 7f9a406

Browse files
authored
Merge pull request #22 from misteinb/bugfix/date-picker-should-not-open-on-focus
remove on focus behavior. turn calendar icon into a button
2 parents 21cfd02 + 12274dd commit 7f9a406

File tree

5 files changed

+25
-24
lines changed

5 files changed

+25
-24
lines changed

CHANGELOG.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# CHANGELOG
22

3+
## v2.0.5
4+
### Fixed
5+
- date picker should not open when input receives focus
36

47
## v2.0.4
58
### Fixed
@@ -8,7 +11,7 @@
811

912
## v2.0.3
1013
### Fixed
11-
- add outline for primary button
14+
- add outline for primary button
1215
- upgrade fluent css version
1316

1417
## v2.0.2

lib/components/DateTime/DatePicker.scss

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -96,17 +96,17 @@ $calc-margin: 5px;
9696
}
9797

9898
.date-picker-calendar-icon {
99-
@include md-box(absolute, float-right);
99+
@include md-box(absolute);
100100
font-size: $font-size-small;
101101
line-height: $line-height-icon;
102-
padding: $grid-size;
103-
top: $grid-size;
104-
right: 2*$grid-size;
102+
top: 0;
103+
right: 0;
105104
border: none;
106105
background-color: transparent;
107-
outline: none;
108-
pointer-events: none;
109-
cursor: pointer;
106+
107+
&:focus:not(:disabled) {
108+
outline-offset: -2px;
109+
}
110110
}
111111

112112
.date-picker-dropdown:not(.above) {

lib/components/DateTime/DatePicker.tsx

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
import * as React from 'react';
22
import * as classNames from 'classnames/bind';
3-
import {DivProps, SpanProps, InputProps, Elements as Attr, mergeAttributeObjects} from '../../Attributes';
3+
import {DivProps, InputProps, Elements as Attr, mergeAttributeObjects} from '../../Attributes';
44
import {Calendar, CalendarAttributes} from './Calendar';
5-
import {Icon, IconSize, IconAttributes} from '../Icon';
5+
import {IconAttributes} from '../Icon';
66
import {Dropdown, DropdownAttributes} from '../Dropdown';
7-
import {replaceAt, formatDate, placeholders} from './helpers';
7+
import {formatDate, placeholders} from './helpers';
88
import {keyCode, MethodDate, dateIsValid, DateFormat} from '../../Common';
9+
import { ActionTriggerButton } from '../ActionTrigger';
910
const css = classNames.bind(require('./DatePicker.scss'));
1011

1112
export interface DatePickerType {}
@@ -338,7 +339,7 @@ export class DatePicker extends React.Component<DatePickerProps, Partial<DatePic
338339
}
339340
}
340341

341-
onFocus = () => {
342+
onIconClick = () => {
342343
this.setState({visible: true});
343344
}
344345

@@ -354,24 +355,24 @@ export class DatePicker extends React.Component<DatePickerProps, Partial<DatePic
354355
}
355356
}
356357

357-
onPaste = (event) => {
358+
onPaste = () => {
358359
this.paste = true;
359360
}
360361

361362
calendarRef = (element: Calendar) => {
362363
this.calendar = element;
363364
}
364365

366+
onOuterEvent = () => this.setState({visible: false});
367+
365368
render() {
366369
const containerClassName = css('date-picker-container', this.props.className);
367-
const dropdownClassName = css('date-picker-dropdown', {
368-
'date-picker-above': this.props.showAbove
369-
});
370370

371-
const icon = <Icon
371+
const icon = <ActionTriggerButton
372372
icon='calendar'
373-
size={IconSize.xsmall}
374373
className={css('date-picker-calendar-icon')}
374+
onClick={this.onIconClick}
375+
disabled={this.props.disabled}
375376
attr={this.props.attr.inputIcon}
376377
/>;
377378

@@ -426,7 +427,7 @@ export class DatePicker extends React.Component<DatePickerProps, Partial<DatePic
426427
*/
427428
onMouseEnter={() => {}}
428429
outerEvents={['click', 'focusin']}
429-
onOuterEvent={(event) => this.setState({visible: false})}
430+
onOuterEvent={this.onOuterEvent}
430431
attr={mergeAttributeObjects(
431432
this.props.attr,
432433
{
@@ -447,7 +448,6 @@ export class DatePicker extends React.Component<DatePickerProps, Partial<DatePic
447448
value={this.state.value}
448449
className={inputClassName}
449450
placeholder={placeholder}
450-
onFocus={this.onFocus}
451451
onChange={this.onChange}
452452
onPaste={this.onPaste}
453453
onKeyUp={this.onKeyUp}

lib/components/DateTime/DateTimeField.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,8 @@ import * as classNames from 'classnames/bind';
33
import { MethodNode, dateIsValid, DateFormat } from '../../Common';
44
import { FormField, FormFieldAttributes } from '../Field/FormField';
55
/** This import solves an error with exports of FormFieldAttributes defaults */
6-
import { FormErrorAttributes } from '../Field/FormError';
76
import { TimeInput, TimeInputAttributes } from './TimeInput';
8-
import { DatePicker, DatePickerProps, DatePickerAttributes } from './DatePicker';
7+
import { DatePicker, DatePickerAttributes } from './DatePicker';
98
import { DivProps, SpanProps, Elements as Attr } from '../../Attributes';
109
const css = classNames.bind(require('./DateTimeField.scss'));
1110

@@ -132,7 +131,6 @@ export class DateTimeField extends React.Component<DateTimeFieldProps, Partial<D
132131
}
133132

134133
getInitialState(props: DateTimeFieldProps): DateTimeFieldState {
135-
let datetime = null, timeValue = null, dateValue = null;
136134
const local = props.localTimezone;
137135
let invalid = false;
138136
let initialValue = null;

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@azure-iot/ux-fluent-controls",
3-
"version": "2.0.4",
3+
"version": "2.0.5",
44
"description": "Azure IoT Fluent React Controls",
55
"main": "./lib/index.js",
66
"types": "./lib/index.d.ts",

0 commit comments

Comments
 (0)