Skip to content

Commit

Permalink
[EuiFilterSelectItem] Convert to Emotion + mark as deprecated (#6982)
Browse files Browse the repository at this point in the history
  • Loading branch information
cee-chen authored Jul 25, 2023
1 parent e7549ac commit 26a5d3d
Show file tree
Hide file tree
Showing 13 changed files with 163 additions and 98 deletions.
15 changes: 7 additions & 8 deletions src-docs/src/views/filter_group/filter_group.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import React, { useState } from 'react';

import {
EuiPopover,
EuiFilterGroup,
EuiFilterButton,
EuiPopover,
EuiSelectableMessage,
EuiIcon,
EuiSpacer,
} from '../../../../src/components';
Expand Down Expand Up @@ -85,13 +86,11 @@ export default () => {
closePopover={closePopover}
panelPaddingSize="none"
>
<div className="euiFilterSelect__note">
<div className="euiFilterSelect__noteContent">
<EuiIcon type="minusInCircle" />
<EuiSpacer size="xs" />
<p>No filters found</p>
</div>
</div>
<EuiSelectableMessage>
<EuiIcon type="minusInCircle" />
<EuiSpacer size="xs" />
<p>No filters found</p>
</EuiSelectableMessage>
</EuiPopover>
<EuiFilterButton
numFilters={12}
Expand Down
44 changes: 22 additions & 22 deletions src/components/combo_box/__snapshots__/combo_box.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -531,7 +531,7 @@ exports[`props option.prepend & option.append renders in the options dropdown 1`
>
<button
aria-selected="false"
class="euiFilterSelectItem"
class="euiFilterSelectItem emotion-euiFilterSelectItem"
id="generated-id__option-0"
role="option"
style="position: absolute; left: 0px; top: 0px; height: 29px; width: 100%;"
Expand All @@ -542,7 +542,7 @@ exports[`props option.prepend & option.append renders in the options dropdown 1`
class="euiFlexGroup emotion-euiFlexGroup-s-flexStart-center-row"
>
<span
class="euiFlexItem euiFilterSelectItem__content emotion-euiFlexItem-grow-1"
class="euiFlexItem euiFilterSelectItem__content eui-textTruncate emotion-euiFlexItem-grow-1"
>
<span
class="euiComboBoxOption__contentWrapper"
Expand All @@ -567,7 +567,7 @@ exports[`props option.prepend & option.append renders in the options dropdown 1`
</button>
<button
aria-selected="false"
class="euiFilterSelectItem"
class="euiFilterSelectItem emotion-euiFilterSelectItem"
id="generated-id__option-1"
role="option"
style="position: absolute; left: 0px; top: 29px; height: 29px; width: 100%;"
Expand All @@ -578,7 +578,7 @@ exports[`props option.prepend & option.append renders in the options dropdown 1`
class="euiFlexGroup emotion-euiFlexGroup-s-flexStart-center-row"
>
<span
class="euiFlexItem euiFilterSelectItem__content emotion-euiFlexItem-grow-1"
class="euiFlexItem euiFilterSelectItem__content eui-textTruncate emotion-euiFlexItem-grow-1"
>
<span
class="euiComboBoxOption__contentWrapper"
Expand Down Expand Up @@ -684,7 +684,7 @@ exports[`props options list is rendered 1`] = `
>
<button
aria-selected="false"
class="euiFilterSelectItem"
class="euiFilterSelectItem emotion-euiFilterSelectItem"
data-test-subj="titanOption"
id="generated-id__option-0"
role="option"
Expand All @@ -696,7 +696,7 @@ exports[`props options list is rendered 1`] = `
class="euiFlexGroup emotion-euiFlexGroup-s-flexStart-center-row"
>
<span
class="euiFlexItem euiFilterSelectItem__content emotion-euiFlexItem-grow-1"
class="euiFlexItem euiFilterSelectItem__content eui-textTruncate emotion-euiFlexItem-grow-1"
>
<span
class="euiComboBoxOption__contentWrapper"
Expand All @@ -712,7 +712,7 @@ exports[`props options list is rendered 1`] = `
</button>
<button
aria-selected="false"
class="euiFilterSelectItem"
class="euiFilterSelectItem emotion-euiFilterSelectItem"
id="generated-id__option-1"
role="option"
style="position: absolute; left: 0px; top: 29px; height: 29px; width: 100%;"
Expand All @@ -723,7 +723,7 @@ exports[`props options list is rendered 1`] = `
class="euiFlexGroup emotion-euiFlexGroup-s-flexStart-center-row"
>
<span
class="euiFlexItem euiFilterSelectItem__content emotion-euiFlexItem-grow-1"
class="euiFlexItem euiFilterSelectItem__content eui-textTruncate emotion-euiFlexItem-grow-1"
>
<span
class="euiComboBoxOption__contentWrapper"
Expand All @@ -739,7 +739,7 @@ exports[`props options list is rendered 1`] = `
</button>
<button
aria-selected="false"
class="euiFilterSelectItem"
class="euiFilterSelectItem emotion-euiFilterSelectItem"
id="generated-id__option-2"
role="option"
style="position: absolute; left: 0px; top: 58px; height: 29px; width: 100%;"
Expand All @@ -750,7 +750,7 @@ exports[`props options list is rendered 1`] = `
class="euiFlexGroup emotion-euiFlexGroup-s-flexStart-center-row"
>
<span
class="euiFlexItem euiFilterSelectItem__content emotion-euiFlexItem-grow-1"
class="euiFlexItem euiFilterSelectItem__content eui-textTruncate emotion-euiFlexItem-grow-1"
>
<span
class="euiComboBoxOption__contentWrapper"
Expand All @@ -766,7 +766,7 @@ exports[`props options list is rendered 1`] = `
</button>
<button
aria-selected="false"
class="euiFilterSelectItem"
class="euiFilterSelectItem emotion-euiFilterSelectItem"
id="generated-id__option-3"
role="option"
style="position: absolute; left: 0px; top: 87px; height: 29px; width: 100%;"
Expand All @@ -777,7 +777,7 @@ exports[`props options list is rendered 1`] = `
class="euiFlexGroup emotion-euiFlexGroup-s-flexStart-center-row"
>
<span
class="euiFlexItem euiFilterSelectItem__content emotion-euiFlexItem-grow-1"
class="euiFlexItem euiFilterSelectItem__content eui-textTruncate emotion-euiFlexItem-grow-1"
>
<span
class="euiComboBoxOption__contentWrapper"
Expand All @@ -793,7 +793,7 @@ exports[`props options list is rendered 1`] = `
</button>
<button
aria-selected="false"
class="euiFilterSelectItem"
class="euiFilterSelectItem emotion-euiFilterSelectItem"
id="generated-id__option-4"
role="option"
style="position: absolute; left: 0px; top: 116px; height: 29px; width: 100%;"
Expand All @@ -804,7 +804,7 @@ exports[`props options list is rendered 1`] = `
class="euiFlexGroup emotion-euiFlexGroup-s-flexStart-center-row"
>
<span
class="euiFlexItem euiFilterSelectItem__content emotion-euiFlexItem-grow-1"
class="euiFlexItem euiFilterSelectItem__content eui-textTruncate emotion-euiFlexItem-grow-1"
>
<span
class="euiComboBoxOption__contentWrapper"
Expand All @@ -820,7 +820,7 @@ exports[`props options list is rendered 1`] = `
</button>
<button
aria-selected="false"
class="euiFilterSelectItem"
class="euiFilterSelectItem emotion-euiFilterSelectItem"
id="generated-id__option-5"
role="option"
style="position: absolute; left: 0px; top: 145px; height: 29px; width: 100%;"
Expand All @@ -831,7 +831,7 @@ exports[`props options list is rendered 1`] = `
class="euiFlexGroup emotion-euiFlexGroup-s-flexStart-center-row"
>
<span
class="euiFlexItem euiFilterSelectItem__content emotion-euiFlexItem-grow-1"
class="euiFlexItem euiFilterSelectItem__content eui-textTruncate emotion-euiFlexItem-grow-1"
>
<span
class="euiComboBoxOption__contentWrapper"
Expand All @@ -847,7 +847,7 @@ exports[`props options list is rendered 1`] = `
</button>
<button
aria-selected="false"
class="euiFilterSelectItem"
class="euiFilterSelectItem emotion-euiFilterSelectItem"
id="generated-id__option-6"
role="option"
style="position: absolute; left: 0px; top: 174px; height: 29px; width: 100%;"
Expand All @@ -858,7 +858,7 @@ exports[`props options list is rendered 1`] = `
class="euiFlexGroup emotion-euiFlexGroup-s-flexStart-center-row"
>
<span
class="euiFlexItem euiFilterSelectItem__content emotion-euiFlexItem-grow-1"
class="euiFlexItem euiFilterSelectItem__content eui-textTruncate emotion-euiFlexItem-grow-1"
>
<span
class="euiComboBoxOption__contentWrapper"
Expand All @@ -874,7 +874,7 @@ exports[`props options list is rendered 1`] = `
</button>
<button
aria-selected="false"
class="euiFilterSelectItem"
class="euiFilterSelectItem emotion-euiFilterSelectItem"
id="generated-id__option-7"
role="option"
style="position: absolute; left: 0px; top: 203px; height: 29px; width: 100%;"
Expand All @@ -885,7 +885,7 @@ exports[`props options list is rendered 1`] = `
class="euiFlexGroup emotion-euiFlexGroup-s-flexStart-center-row"
>
<span
class="euiFlexItem euiFilterSelectItem__content emotion-euiFlexItem-grow-1"
class="euiFlexItem euiFilterSelectItem__content eui-textTruncate emotion-euiFlexItem-grow-1"
>
<span
class="euiComboBoxOption__contentWrapper"
Expand All @@ -901,7 +901,7 @@ exports[`props options list is rendered 1`] = `
</button>
<button
aria-selected="false"
class="euiFilterSelectItem"
class="euiFilterSelectItem emotion-euiFilterSelectItem"
id="generated-id__option-8"
role="option"
style="position: absolute; left: 0px; top: 232px; height: 29px; width: 100%;"
Expand All @@ -912,7 +912,7 @@ exports[`props options list is rendered 1`] = `
class="euiFlexGroup emotion-euiFlexGroup-s-flexStart-center-row"
>
<span
class="euiFlexItem euiFilterSelectItem__content emotion-euiFlexItem-grow-1"
class="euiFlexItem euiFilterSelectItem__content eui-textTruncate emotion-euiFlexItem-grow-1"
>
<span
class="euiComboBoxOption__contentWrapper"
Expand Down
17 changes: 11 additions & 6 deletions src/components/combo_box/combo_box.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
*/

import React, { ReactNode } from 'react';
import { fireEvent } from '@testing-library/react';
import { shallow, mount } from 'enzyme';
import { render } from '../../test/rtl';
import {
Expand Down Expand Up @@ -297,18 +298,22 @@ test('does not show multiple checkmarks with duplicate labels', () => {
label: 'Tethys',
},
];
const component = mount(
const { baseElement, getByTestSubject } = render(
<EuiComboBox
singleSelection={{ asPlainText: true }}
options={options}
selectedOptions={[options[1]]}
/>
);

const searchInput = findTestSubject(component, 'comboBoxSearchInput');
searchInput.simulate('focus');

expect(component.find('EuiFilterSelectItem[checked="on"]').length).toBe(1);
fireEvent.focus(getByTestSubject('comboBoxSearchInput'));

const dropdownOptions = baseElement.querySelectorAll('.euiFilterSelectItem');
expect(
dropdownOptions[0]!.querySelector('[data-euiicon-type="check"]')
).toBeFalsy();
expect(
dropdownOptions[1]!.querySelector('[data-euiicon-type="check"]')
).toBeTruthy();
});

describe('behavior', () => {
Expand Down
4 changes: 2 additions & 2 deletions src/components/combo_box/combo_box.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ import {
EuiComboBoxOptionsListPosition,
EuiComboBoxSingleSelectionShape,
} from './types';
import { EuiFilterSelectItem } from '../filter_group';
import { EuiFilterSelectItemClass } from '../filter_group/filter_select_item';
import AutosizeInput from 'react-input-autosize';
import { CommonProps } from '../common';
import { EuiFormControlLayoutProps } from '../form';
Expand Down Expand Up @@ -279,7 +279,7 @@ export class EuiComboBox<T> extends Component<
this.toggleButtonRefInstance = ref;
};

optionsRefInstances: Array<RefInstance<EuiFilterSelectItem>> = [];
optionsRefInstances: Array<RefInstance<EuiFilterSelectItemClass>> = [];
optionRefCallback: EuiComboBoxOptionsListProps<T>['optionRef'] = (
index,
ref
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import { EuiComboBoxTitle } from './combo_box_title';
import { EuiI18n } from '../../i18n';
import {
EuiFilterSelectItem,
EuiFilterSelectItemClass,
FilterChecked,
} from '../../filter_group/filter_select_item';
import { htmlIdGenerator } from '../../../services';
Expand Down Expand Up @@ -73,7 +74,10 @@ export type EuiComboBoxOptionsListProps<T> = CommonProps &
onOptionClick?: OptionHandler<T>;
onOptionEnterKey?: OptionHandler<T>;
onScroll?: ListProps['onScroll'];
optionRef: (index: number, node: RefInstance<EuiFilterSelectItem>) => void;
optionRef: (
index: number,
node: RefInstance<EuiFilterSelectItemClass>
) => void;
/**
* Array of EuiComboBoxOptionOption objects. See #EuiComboBoxOptionOption
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`EuiFilterSelectItem is rendered 1`] = `
exports[`EuiFilterSelectItem renders 1`] = `
<button
aria-label="aria-label"
class="euiFilterSelectItem testClass1 testClass2 emotion-euiTestCss"
class="euiFilterSelectItem testClass1 testClass2 emotion-euiFilterSelectItem-euiTestCss"
data-test-subj="test subject string"
role="option"
type="button"
Expand All @@ -19,7 +19,7 @@ exports[`EuiFilterSelectItem is rendered 1`] = `
/>
</div>
<span
class="euiFlexItem euiFilterSelectItem__content emotion-euiFlexItem-grow-1"
class="euiFlexItem euiFilterSelectItem__content eui-textTruncate emotion-euiFlexItem-grow-1"
/>
</span>
</button>
Expand Down
43 changes: 0 additions & 43 deletions src/components/filter_group/_filter_select_item.scss

This file was deleted.

1 change: 0 additions & 1 deletion src/components/filter_group/_index.scss

This file was deleted.

Loading

0 comments on commit 26a5d3d

Please sign in to comment.