Skip to content

Commit 99bccb0

Browse files
committed
fix(blueprint): fix missing props for sort titles
1 parent 32db732 commit 99bccb0

File tree

3 files changed

+78
-5
lines changed

3 files changed

+78
-5
lines changed

packages/blueprint-component-mapper/src/dual-list-select/dual-list-select.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,8 @@ const DualListInternal = ({
143143
LeftMenuItemProps,
144144
RightMenuProps,
145145
RightMenuItemProps,
146+
leftSortTitle,
147+
rightSortTitle,
146148
}) => {
147149
const { buttonGroup, wrapper } = useStyles();
148150

@@ -159,6 +161,7 @@ const DualListInternal = ({
159161
ControlGroupProps={LeftControlGroupProps}
160162
InputGroupProps={LeftInputGroupProps}
161163
ButtonProps={LeftButtonProps}
164+
sortTitle={leftSortTitle}
162165
/>
163166
<List
164167
optionClick={handleOptionsClick}
@@ -216,6 +219,7 @@ const DualListInternal = ({
216219
ControlGroupProps={RightControlGroupProps}
217220
InputGroupProps={RightInputGroupProps}
218221
ButtonProps={RightButtonProps}
222+
sortTitle={rightSortTitle}
219223
/>
220224
<List
221225
optionClick={handleValuesClick}
@@ -279,6 +283,8 @@ DualListInternal.propTypes = {
279283
LeftMenuItemProps: PropTypes.object,
280284
RightMenuProps: PropTypes.object,
281285
RightMenuItemProps: PropTypes.object,
286+
leftSortTitle: PropTypes.string,
287+
rightSortTitle: PropTypes.string,
282288
};
283289

284290
DualListInternal.defaultProps = {
@@ -294,6 +300,8 @@ DualListInternal.defaultProps = {
294300
filterValueTitle: 'Filter selected value',
295301
filterOptionsText: 'Remove your filter to see all options',
296302
filterValueText: 'Remove your filter to see all selected',
303+
leftSortTitle: 'Sort options',
304+
rightSortTitle: 'Sort value',
297305
options: [],
298306
allToLeft: true,
299307
allToRight: true,

packages/blueprint-component-mapper/src/tests/dual-list-select.test.js

Lines changed: 68 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -168,13 +168,76 @@ describe('DualListSelect', () => {
168168
expect(() => screen.getByText('pigeons')).toThrow();
169169
});
170170

171-
// ICON BUTTONS ARE TO REACHABLE
172-
it.skip('sort options', async () => {
173-
render(<FormRenderer {...initialProps} />);
171+
it('sort options', async () => {
172+
const { container } = render(<FormRenderer {...initialProps} />);
173+
174+
expect([...container.getElementsByClassName('bp3-menu-item')].map((el) => el.text)).toEqual([
175+
'cats',
176+
'cats_1',
177+
'cats_2',
178+
'pigeons',
179+
'zebras',
180+
'No selected',
181+
]);
182+
183+
userEvent.click(screen.getByTitle('Sort options'));
184+
185+
expect([...container.getElementsByClassName('bp3-menu-item')].map((el) => el.text)).toEqual([
186+
'zebras',
187+
'pigeons',
188+
'cats_2',
189+
'cats_1',
190+
'cats',
191+
'No selected',
192+
]);
193+
194+
userEvent.click(screen.getByTitle('Sort options'));
195+
196+
expect([...container.getElementsByClassName('bp3-menu-item')].map((el) => el.text)).toEqual([
197+
'cats',
198+
'cats_1',
199+
'cats_2',
200+
'pigeons',
201+
'zebras',
202+
'No selected',
203+
]);
174204
});
175205

176-
it.skip('sort value', async () => {
177-
render(<FormRenderer {...initialProps} />);
206+
it('sort value', async () => {
207+
const { container } = render(
208+
<FormRenderer {...initialProps} initialValues={{ 'dual-list': schema.fields[0].options.map(({ value }) => value) }} />
209+
);
210+
211+
expect([...container.getElementsByClassName('bp3-menu-item')].map((el) => el.text)).toEqual([
212+
'No available options',
213+
'cats',
214+
'cats_1',
215+
'cats_2',
216+
'pigeons',
217+
'zebras',
218+
]);
219+
220+
userEvent.click(screen.getByTitle('Sort value'));
221+
222+
expect([...container.getElementsByClassName('bp3-menu-item')].map((el) => el.text)).toEqual([
223+
'No available options',
224+
'zebras',
225+
'pigeons',
226+
'cats_2',
227+
'cats_1',
228+
'cats',
229+
]);
230+
231+
userEvent.click(screen.getByTitle('Sort value'));
232+
233+
expect([...container.getElementsByClassName('bp3-menu-item')].map((el) => el.text)).toEqual([
234+
'No available options',
235+
'cats',
236+
'cats_1',
237+
'cats_2',
238+
'pigeons',
239+
'zebras',
240+
]);
178241
});
179242

180243
describe('filtered options', () => {

packages/react-renderer-demo/src/doc-components/examples-texts/blueprint/dual-list-select.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ Dual list select is wrapped in a form group, so it accepts all [form group props
2121
|filterValueTitle|String|'Filter selected value'|Placeholder for value filter input|
2222
|filterValueText|String|'Remove your filter to see all selected'|Placeholder for value when there is no filtered value|
2323
|filterOptionsText|String|'Remove your filter to see all options'|Placeholder for options when there is no filtered option|
24+
|leftSortTitle|String|'Sort options'|Accessible title for left sort button.|
25+
|rightSortTitle|String|'Sort value'|Accessible title for right sort button.|
2426

2527
### Options
2628

0 commit comments

Comments
 (0)