Skip to content

Commit 3435925

Browse files
authored
feat(SelectDialog): add searchPlaceholder prop (#8644)
Closes #8637
1 parent 2fe532c commit 3435925

6 files changed

Lines changed: 35 additions & 311 deletions

File tree

cypress.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export default defineConfig({
1212
bundler: 'vite',
1313
},
1414
experimentalRunAllSpecs: true,
15-
excludeSpecPattern: ['**/e2e/**', ...(process.env.CI ? ['**/SelectDialog/**'] : [])],
15+
excludeSpecPattern: ['**/e2e/**'],
1616
},
1717
includeShadowDom: true,
1818
viewportWidth: 1920,

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

Lines changed: 0 additions & 306 deletions
This file was deleted.

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,11 @@ import { SelectDialog } from './index.js';
1616
const meta = {
1717
title: 'Modals & Popovers / SelectDialog',
1818
component: SelectDialog,
19-
argTypes: { children: { control: { disable: true } } },
19+
argTypes: {
20+
children: { control: { disable: true } },
21+
onSearch: { control: { disable: true } },
22+
onCancel: { control: { disable: true } },
23+
},
2024
args: { headerText: 'Select Product', open: isChromatic },
2125
parameters: {
2226
chromatic: { delay: 1000 },

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

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,13 @@ export interface SelectDialogPropTypes
118118
* @since 1.25.0
119119
*/
120120
confirmButtonProps?: Omit<ButtonPropTypes, 'onClick' | 'design'>;
121+
/**
122+
*
123+
* Allows overriding the SearchField's default placeholder text. If not set, the word "Search" in the current local language or English will be used as a placeholder.
124+
*
125+
* __Note:__ The placeholder is used as accessible-name of the input for screen reader support.
126+
*/
127+
searchPlaceholder?: string;
121128
/**
122129
* This event will be fired when the value of the search field is changed by a user - e.g. at each key press
123130
*/
@@ -169,6 +176,7 @@ const SelectDialog = forwardRef<DialogDomRef, SelectDialogPropTypes>((props, ref
169176
selectionMode = ListSelectionMode.Single,
170177
numberOfSelectedItems,
171178
rememberSelections,
179+
searchPlaceholder,
172180
showClearButton,
173181
onClose,
174182
onClear,
@@ -341,9 +349,9 @@ const SelectDialog = forwardRef<DialogDomRef, SelectDialogPropTypes>((props, ref
341349
)}
342350
<Input
343351
className={classNames.input}
344-
accessibleName={i18nBundle.getText(SEARCH)}
352+
accessibleName={searchPlaceholder ?? i18nBundle.getText(SEARCH)}
345353
value={searchValue}
346-
placeholder={i18nBundle.getText(SEARCH)}
354+
placeholder={searchPlaceholder ?? i18nBundle.getText(SEARCH)}
347355
onInput={handleSearchInput}
348356
onKeyUp={handleSearchSubmit}
349357
type={InputType.Search}

packages/main/src/components/SelectDialog/test/SelectDialog.spec.tsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,8 @@ test.describe('SelectDialog', () => {
129129
await expect(page.locator('[accessible-name="Reset"][ui5-icon]')).not.toBeVisible();
130130

131131
const input = page.locator('[ui5-input]');
132+
await expect(input).toHaveAttribute('placeholder', 'Search');
133+
await expect(input).toHaveAttribute('accessible-name', 'Search');
132134
await ui5wc.typeIntoInput(input, 'Test');
133135
await expect(page.getByTestId('input-val')).toHaveText('input: Test');
134136
await expect(page.getByTestId('search-count')).toHaveText('0');
@@ -152,6 +154,12 @@ test.describe('SelectDialog', () => {
152154
await expect(page.getByTestId('input-count')).toHaveText('2');
153155
await expect(page.getByTestId('reset-count')).toHaveText('1');
154156
await expect(page.locator('[accessible-name="Reset"][ui5-icon]')).not.toBeVisible();
157+
158+
await ui5wc.closePopupWithEsc();
159+
await page.getByTestId('set-placeholder').click();
160+
await page.getByTestId('open-btn').click();
161+
await expect(input).toHaveAttribute('placeholder', 'Hello');
162+
await expect(input).toHaveAttribute('accessible-name', 'Hello');
155163
});
156164

157165
test('confirmButtonText', async ({ mount, page }) => {

0 commit comments

Comments
 (0)