Skip to content

Commit e26f690

Browse files
authored
fix(SelectDialog): apply latest Design and A11y specs (#7586)
Fixes #7577
1 parent 5c7dab6 commit e26f690

File tree

3 files changed

+24
-16
lines changed

3 files changed

+24
-16
lines changed

packages/main/src/components/SelectDialog/SelectDialog.cy.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -208,9 +208,10 @@ describe('SelectDialog', () => {
208208
cy.get('@search').should('have.callCount', 2);
209209
cy.get('@input').should('have.callCount', 4);
210210
cy.get('@reset').should('have.callCount', 0);
211-
cy.get('[accessible-name="Reset"][ui5-icon]').click();
211+
cy.get('[part="clear-icon"][ui5-icon]').click();
212212
cy.get('@search').should('have.callCount', 2);
213-
cy.get('@input').should('have.callCount', 4);
213+
// clearing the input via clear button fires input event as well
214+
cy.get('@input').should('have.callCount', 5);
214215
cy.get('@reset').should('have.callCount', 1);
215216
cy.get('[accessible-name="Reset"][ui5-icon]').should('not.exist');
216217
});

packages/main/src/components/SelectDialog/SelectDialog.module.css

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,18 @@
6565

6666
.inputIcon {
6767
cursor: pointer;
68-
color: var(--sapContent_IconColor);
68+
color: var(--sapField_TextColor);
69+
70+
&:hover {
71+
box-shadow: var(--sapField_Hover_Shadow);
72+
background-color: var(--_ui5_input_icon_hover_bg);
73+
}
74+
75+
&:active {
76+
box-shadow: var(--sapField_Hover_Shadow);
77+
color: var(--sapButton_Active_TextColor);
78+
background-color: var(--sapButton_Active_Background);
79+
}
6980
}
7081

7182
.infoBar {

packages/main/src/components/SelectDialog/index.tsx

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,12 @@ import ButtonDesign from '@ui5/webcomponents/dist/types/ButtonDesign.js';
44
import IconMode from '@ui5/webcomponents/dist/types/IconMode.js';
55
import InputType from '@ui5/webcomponents/dist/types/InputType.js';
66
import ListSelectionMode from '@ui5/webcomponents/dist/types/ListSelectionMode.js';
7-
import iconDecline from '@ui5/webcomponents-icons/dist/decline.js';
87
import iconSearch from '@ui5/webcomponents-icons/dist/search.js';
98
import { enrichEventWithDetails, useI18nBundle, useStylesheet, useSyncRef } from '@ui5/webcomponents-react-base';
109
import { clsx } from 'clsx';
1110
import type { ReactNode } from 'react';
1211
import { forwardRef, useEffect, useState } from 'react';
13-
import { CANCEL, CLEAR, RESET, SEARCH, SELECT, SELECTED } from '../../i18n/i18n-defaults.js';
12+
import { CANCEL, CLEAR, SEARCH, SELECT, SELECTED } from '../../i18n/i18n-defaults.js';
1413
import { Button, Dialog, FlexBox, FlexBoxAlignItems, Icon, Input, List, Text, Title } from '../../index.js';
1514
import type { Ui5CustomEvent } from '../../types/index.js';
1615
import type {
@@ -113,6 +112,7 @@ export interface SelectDialogPropTypes
113112
onSearch?:
114113
| ((event: Ui5CustomEvent<InputDomRef, { value: string }>) => void)
115114
| ((event: Ui5CustomEvent<IconDomRef, { value: string }>) => void);
115+
// todo: remove `nativeDetail` in next major version
116116
/**
117117
* This event will be fired when the reset button has been clicked in the search field or when the dialog is closed.
118118
*/
@@ -196,6 +196,10 @@ const SelectDialog = forwardRef<DialogDomRef, SelectDialogPropTypes>((props, ref
196196
};
197197

198198
const handleSearchInput = (e) => {
199+
if (!e.target.value && e.detail.inputType === '') {
200+
handleResetSearch(e);
201+
}
202+
199203
if (typeof onSearchInput === 'function') {
200204
onSearchInput(enrichEventWithDetails(e, { value: e.target.value }));
201205
}
@@ -318,20 +322,12 @@ const SelectDialog = forwardRef<DialogDomRef, SelectDialogPropTypes>((props, ref
318322
onInput={handleSearchInput}
319323
onKeyUp={handleSearchSubmit}
320324
type={InputType.Search}
325+
showClearIcon
321326
icon={
322327
<>
323-
{searchValue && (
324-
<Icon
325-
accessibleName={i18nBundle.getText(RESET)}
326-
title={i18nBundle.getText(RESET)}
327-
name={iconDecline}
328-
mode={IconMode.Interactive}
329-
onClick={handleResetSearch}
330-
className={classNames.inputIcon}
331-
/>
332-
)}
328+
{/*Decorative type while still being interactive is by design (see SapUI5 implementation)*/}
333329
<Icon
334-
mode={IconMode.Interactive}
330+
mode={IconMode.Decorative}
335331
name={iconSearch}
336332
className={classNames.inputIcon}
337333
onClick={handleSearchSubmit}

0 commit comments

Comments
 (0)