Skip to content

Commit

Permalink
Revert "[EuiSuperDatePicker] Bypass formatting null dates (elastic#…
Browse files Browse the repository at this point in the history
…3750)"

This reverts commit 1237c3c.
  • Loading branch information
anishagg17 committed Jul 20, 2020
1 parent d89d54b commit 055c265
Show file tree
Hide file tree
Showing 6 changed files with 963 additions and 273 deletions.
1 change: 0 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

- Fixed `EuiComboBox` always showing a scrollbar ([#3744](https://github.com/elastic/eui/pull/3744))
- Replaced `react-focus-lock` with `react-focus-on` ([#3631](https://github.com/elastic/eui/pull/3631))
- Fixed errors in `EuiSuperDatePicker` related to invalid and `null` date formatting ([#3750](https://github.com/elastic/eui/pull/3750))

## [`27.1.0`](https://github.com/elastic/eui/tree/v27.1.0)

Expand Down
85 changes: 28 additions & 57 deletions packages/react-datepicker.js
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,11 @@ UntouchabilityChecker.prototype.isUntouchable = function isUntouchable(node) {

var tabbable_1 = tabbable;

var tabbable$1 = /*#__PURE__*/Object.freeze({
default: tabbable_1,
__moduleExports: tabbable_1
});

var immutable = extend;

var hasOwnProperty = Object.prototype.hasOwnProperty;
Expand All @@ -232,12 +237,7 @@ function extend() {
return target
}

var immutable$1 = /*#__PURE__*/Object.freeze({
default: immutable,
__moduleExports: immutable
});

var xtend = ( immutable$1 && immutable ) || immutable$1;
var tabbable$2 = ( tabbable$1 && tabbable_1 ) || tabbable$1;

var listeningFocusTrap = null;

Expand All @@ -246,7 +246,7 @@ function focusTrap(element, userOptions) {
var container =
typeof element === 'string' ? doc.querySelector(element) : element;

var config = xtend(
var config = immutable(
{
returnFocusOnDeactivate: true,
escapeDeactivates: true
Expand Down Expand Up @@ -418,7 +418,7 @@ function focusTrap(element, userOptions) {
if (container.contains(e.target)) return;
if (config.clickOutsideDeactivates) {
deactivate({
returnFocus: !tabbable_1.isFocusable(e.target)
returnFocus: !tabbable$2.isFocusable(e.target)
});
} else {
e.preventDefault();
Expand Down Expand Up @@ -473,7 +473,7 @@ function focusTrap(element, userOptions) {
}

function updateTabbableNodes() {
var tabbableNodes = tabbable_1(container);
var tabbableNodes = tabbable$2(container);
state.firstTabbableNode = tabbableNodes[0] || getInitialFocusNode();
state.lastTabbableNode =
tabbableNodes[tabbableNodes.length - 1] || getInitialFocusNode();
Expand Down Expand Up @@ -3027,16 +3027,9 @@ var Month = function (_React$Component) {
}
};

_this.onBlur = function () {
if (_this.props.accessibleMode) {
_this.setState({ readInstructions: false });
}
};

_this.onInputKeyDown = function (event) {
var eventKey = event.key;
// `preSelection` can be `null` but `day` is required. Use it as a fallback if necessary for invalid entries.
var copy = _this.props.preSelection ? newDate(_this.props.preSelection) : newDate(_this.props.day);
var copy = newDate(_this.props.preSelection);
var newSelection = void 0;
switch (eventKey) {
case "ArrowLeft":
Expand Down Expand Up @@ -3066,7 +3059,7 @@ var Month = function (_React$Component) {
case " ":
case "Enter":
event.preventDefault();
_this.handleDayClick(copy, event);
_this.handleDayClick(_this.props.preSelection, event);
break;
}
if (!newSelection) return; // Let the input component handle this keydown
Expand Down Expand Up @@ -3168,7 +3161,8 @@ var Month = function (_React$Component) {
"p",
{ "aria-live": true },
"You are focused on a calendar. Use the arrow keys to navigate the days in the month. Use the page up and down keys to navigate from month to month. Use the home and end keys to navigate from year to year.",
this.props.preSelection ? formatDate(this.props.preSelection, this.dayFormat) + " is the\n currently focused date." : "No date is currently focused."
formatDate(this.props.preSelection, this.dayFormat),
" is the currently focused date."
);
}

Expand All @@ -3181,8 +3175,7 @@ var Month = function (_React$Component) {
"aria-label": "month-" + this.props.day.format("YYYY-MM"),
tabIndex: this.props.accessibleMode ? 0 : -1,
onKeyDown: this.onInputKeyDown,
onFocus: this.onFocus,
onBlur: this.onBlur
onFocus: this.onFocus
},
React__default.createElement(
ScreenReaderOnly,
Expand Down Expand Up @@ -3318,10 +3311,8 @@ var Time = function (_React$Component) {
}

// update preSelection to the selection
this.setState(function (prevState) {
return {
preSelection: prevState.selected
};
this.setState({
preSelection: this.props.selected
});
}

Expand Down Expand Up @@ -3364,7 +3355,8 @@ var Time = function (_React$Component) {
"p",
{ "aria-live": true },
"You are a in a time selector. Use the up and down keys to select from other common times then press enter to confirm.",
this.state.preSelection ? formatDate(this.state.preSelection, this.timeFormat) + " is currently\n focused." : "No time is currently focused."
formatDate(this.state.preSelection, this.timeFormat),
" is currently focused."
);
}

Expand Down Expand Up @@ -3457,7 +3449,7 @@ var _initialiseProps = function _initialiseProps() {

this.onBlur = function () {
if (_this3.props.accessibleMode) {
_this3.setState({ readInstructions: false, isFocused: false });
_this3.setState({ isFocused: false });
}
};

Expand Down Expand Up @@ -4540,24 +4532,17 @@ var _objectKeysInternal = function (object, names) {
return result;
};

var _objectKeysInternal$1 = /*#__PURE__*/Object.freeze({
default: _objectKeysInternal,
__moduleExports: _objectKeysInternal
});

// IE 8- don't enum bug keys
var _enumBugKeys = (
'constructor,hasOwnProperty,isPrototypeOf,propertyIsEnumerable,toLocaleString,toString,valueOf'
).split(',');

var $keys = ( _objectKeysInternal$1 && _objectKeysInternal ) || _objectKeysInternal$1;

// 19.1.2.14 / 15.2.3.14 Object.keys(O)



var _objectKeys = Object.keys || function keys(O) {
return $keys(O, _enumBugKeys);
return _objectKeysInternal(O, _enumBugKeys);
};

var f$1 = Object.getOwnPropertySymbols;
Expand Down Expand Up @@ -4612,40 +4597,26 @@ var _objectAssign = !$assign || _fails(function () {
} return T;
} : $assign;

var _objectAssign$1 = /*#__PURE__*/Object.freeze({
default: _objectAssign,
__moduleExports: _objectAssign
});

var require$$0 = ( _objectAssign$1 && _objectAssign ) || _objectAssign$1;

// 19.1.3.1 Object.assign(target, source)


_export(_export.S + _export.F, 'Object', { assign: require$$0 });
_export(_export.S + _export.F, 'Object', { assign: _objectAssign });

var assign = _core.Object.assign;

var assign$1 = /*#__PURE__*/Object.freeze({
default: assign,
__moduleExports: assign
});

var require$$0$1 = ( assign$1 && assign ) || assign$1;

var assign$2 = createCommonjsModule(function (module) {
module.exports = { "default": require$$0$1, __esModule: true };
var assign$1 = createCommonjsModule(function (module) {
module.exports = { "default": assign, __esModule: true };
});

unwrapExports(assign$2);
unwrapExports(assign$1);

var _extends$1 = createCommonjsModule(function (module, exports) {

exports.__esModule = true;



var _assign2 = _interopRequireDefault(assign$2);
var _assign2 = _interopRequireDefault(assign$1);

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

Expand Down Expand Up @@ -5020,7 +4991,7 @@ var _isArray = Array.isArray || function isArray(arg) {
var hiddenKeys = _enumBugKeys.concat('length', 'prototype');

var f$4 = Object.getOwnPropertyNames || function getOwnPropertyNames(O) {
return $keys(O, hiddenKeys);
return _objectKeysInternal(O, hiddenKeys);
};

var _objectGopn = {
Expand Down Expand Up @@ -5311,10 +5282,10 @@ var symbol$1 = /*#__PURE__*/Object.freeze({
__moduleExports: symbol
});

var require$$0$2 = ( symbol$1 && symbol ) || symbol$1;
var require$$0 = ( symbol$1 && symbol ) || symbol$1;

var symbol$2 = createCommonjsModule(function (module) {
module.exports = { "default": require$$0$2, __esModule: true };
module.exports = { "default": require$$0, __esModule: true };
});

unwrapExports(symbol$2);
Expand Down
Loading

0 comments on commit 055c265

Please sign in to comment.