Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions src/components/combo_box/__snapshots__/combo_box.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ exports[`EuiComboBox is rendered 1`] = `
exports[`props aria-label attribute is rendered 1`] = `
<div
className="euiComboBox"
onBlur={[Function]}
onKeyDown={[Function]}
>
<EuiComboBoxInput
Expand Down Expand Up @@ -94,6 +95,7 @@ exports[`props aria-label attribute is rendered 1`] = `
exports[`props aria-labelledby attribute is rendered 1`] = `
<div
className="euiComboBox"
onBlur={[Function]}
onKeyDown={[Function]}
>
<EuiComboBoxInput
Expand Down Expand Up @@ -127,6 +129,7 @@ exports[`props aria-labelledby attribute is rendered 1`] = `
exports[`props autoFocus is rendered 1`] = `
<div
className="euiComboBox"
onBlur={[Function]}
onKeyDown={[Function]}
>
<EuiComboBoxInput
Expand Down Expand Up @@ -168,6 +171,7 @@ exports[`props autoFocus is rendered 1`] = `
exports[`props custom ID is rendered 1`] = `
<div
className="euiComboBox"
onBlur={[Function]}
onKeyDown={[Function]}
>
<EuiComboBoxInput
Expand Down Expand Up @@ -209,6 +213,7 @@ exports[`props custom ID is rendered 1`] = `
exports[`props delimiter is rendered 1`] = `
<div
className="euiComboBox"
onBlur={[Function]}
onKeyDown={[Function]}
>
<EuiComboBoxInput
Expand Down Expand Up @@ -250,6 +255,7 @@ exports[`props delimiter is rendered 1`] = `
exports[`props full width is rendered 1`] = `
<div
className="euiComboBox euiComboBox--fullWidth"
onBlur={[Function]}
onKeyDown={[Function]}
>
<EuiComboBoxInput
Expand Down Expand Up @@ -288,6 +294,7 @@ exports[`props full width is rendered 1`] = `
exports[`props isClearable=false disallows user from clearing input when no options are selected 1`] = `
<div
className="euiComboBox"
onBlur={[Function]}
onKeyDown={[Function]}
>
<EuiComboBoxInput
Expand Down Expand Up @@ -319,6 +326,7 @@ exports[`props isClearable=false disallows user from clearing input when no opti
exports[`props isClearable=false disallows user from clearing input when options are selected 1`] = `
<div
className="euiComboBox"
onBlur={[Function]}
onKeyDown={[Function]}
>
<EuiComboBoxInput
Expand Down Expand Up @@ -359,6 +367,7 @@ exports[`props isClearable=false disallows user from clearing input when options
exports[`props isDisabled is rendered 1`] = `
<div
className="euiComboBox euiComboBox-isDisabled"
onBlur={[Function]}
onKeyDown={[Function]}
>
<EuiComboBoxInput
Expand Down Expand Up @@ -722,6 +731,7 @@ exports[`props options list is rendered 1`] = `
exports[`props selectedOptions are rendered 1`] = `
<div
className="euiComboBox"
onBlur={[Function]}
onKeyDown={[Function]}
>
<EuiComboBoxInput
Expand Down Expand Up @@ -763,6 +773,7 @@ exports[`props selectedOptions are rendered 1`] = `
exports[`props singleSelection is rendered 1`] = `
<div
className="euiComboBox"
onBlur={[Function]}
onKeyDown={[Function]}
>
<EuiComboBoxInput
Expand Down Expand Up @@ -801,6 +812,7 @@ exports[`props singleSelection is rendered 1`] = `
exports[`props singleSelection prepend and append is rendered 1`] = `
<div
className="euiComboBox euiComboBox--prepended euiComboBox--appended euiComboBox-isOpen"
onBlur={[Function]}
onKeyDown={[Function]}
>
<EuiComboBoxInput
Expand Down Expand Up @@ -843,6 +855,7 @@ exports[`props singleSelection prepend and append is rendered 1`] = `
exports[`props singleSelection selects existing option when opened 1`] = `
<div
className="euiComboBox euiComboBox-isOpen"
onBlur={[Function]}
onKeyDown={[Function]}
>
<EuiComboBoxInput
Expand Down
31 changes: 4 additions & 27 deletions src/components/combo_box/combo_box.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -229,22 +229,9 @@ export class EuiComboBox<T> extends Component<
// Refs
comboBoxRefInstance: RefInstance<HTMLDivElement> = null;
comboBoxRefCallback: RefCallback<HTMLDivElement> = (ref) => {
// IE11 doesn't support the `relatedTarget` event property for blur events
// but does add it for focusout. React doesn't support `onFocusOut` so here we are.
if (this.comboBoxRefInstance) {
this.comboBoxRefInstance.removeEventListener(
'focusout',
this.onContainerBlur
);
}

this.comboBoxRefInstance = ref;

if (this.comboBoxRefInstance) {
this.comboBoxRefInstance.addEventListener(
'focusout',
this.onContainerBlur
);
const comboBoxBounds = this.comboBoxRefInstance.getBoundingClientRect();
this.setState({
width: comboBoxBounds.width,
Expand Down Expand Up @@ -549,18 +536,9 @@ export class EuiComboBox<T> extends Component<
}
};

onContainerBlur: EventListener = (event) => {
onContainerBlur: FocusEventHandler<HTMLDivElement> = (event) => {
// close the options list, unless the user clicked on an option

/**
* FireFox returns `relatedTarget` as `null` for security reasons, but provides a proprietary `explicitOriginalTarget`.
* @see https://developer.mozilla.org/en-US/docs/Web/API/Event/explicitOriginalTarget
*/
const focusEvent = event as FocusEvent & {
explicitOriginalTarget: EventTarget;
};
const relatedTarget = (focusEvent.relatedTarget ||
focusEvent.explicitOriginalTarget) as Node | null;
const { relatedTarget } = event;

const focusedInOptionsList =
relatedTarget &&
Expand All @@ -575,9 +553,7 @@ export class EuiComboBox<T> extends Component<
this.closeList();

if (this.props.onBlur) {
this.props.onBlur(
(event as unknown) as React.FocusEvent<HTMLDivElement>
);
this.props.onBlur(event);
}
this.setState({ hasFocus: false });

Expand Down Expand Up @@ -1046,6 +1022,7 @@ export class EuiComboBox<T> extends Component<
className={classes}
data-test-subj={dataTestSubj}
onKeyDown={this.onKeyDown}
onBlur={this.onContainerBlur}
ref={this.comboBoxRefCallback}
>
<EuiComboBoxInput
Expand Down
21 changes: 6 additions & 15 deletions src/components/form/field_search/field_search.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -141,23 +141,14 @@ export class EuiFieldSearch extends Component<
nativeInputValueSetter.call(this.inputElement, '');
}

// dispatch input event, with IE11 support/fallback
let event;
if ('Event' in window && typeof Event === 'function') {
event = new Event('input', {
bubbles: true,
cancelable: false,
});
} else {
// IE11
event = document.createEvent('Event');
event.initEvent('input', true, false);
}
// dispatch input event
const event = new Event('input', {
bubbles: true,
cancelable: false,
});

if (this.inputElement) {
if (event) {
this.inputElement.dispatchEvent(event);
}
this.inputElement.dispatchEvent(event);
// set focus on the search field
this.inputElement.focus();
this.inputElement.dispatchEvent(new Event('change'));
Expand Down
2 changes: 1 addition & 1 deletion src/components/form/range/range_input.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export const EuiRangeInput: FunctionComponent<EuiRangeInputProps> = ({
autoSize = true,
...rest
}) => {
// Chrome will properly size the input based on the max value, but FF & IE do not.
// Chrome will properly size the input based on the max value, but FF does not.
// Calculate the width of the input based on highest number of characters.
// Add 2 to accommodate for input stepper
const widthStyle = autoSize
Expand Down
Loading