Skip to content

Commit cb5c05d

Browse files
committed
fix: search and sort props need to be passed to SearchSort component
1 parent f533168 commit cb5c05d

1 file changed

Lines changed: 42 additions & 42 deletions

File tree

src/editors/sharedComponents/SelectionModal/SearchSort.jsx

Lines changed: 42 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,7 @@ import React from 'react';
22
import PropTypes from 'prop-types';
33

44
import {
5-
ActionRow,
6-
Dropdown,
7-
Form,
8-
Icon,
9-
IconButton,
10-
SelectMenu,
11-
MenuItem,
5+
ActionRow, Dropdown, Form, Icon, IconButton, SelectMenu, MenuItem,
126
} from '@openedx/paragon';
137
import { Check, Close, Search } from '@openedx/paragon/icons';
148
import {
@@ -18,13 +12,14 @@ import {
1812

1913
import messages from './messages';
2014
import './index.scss';
21-
import { sortKeys, sortMessages } from '../../containers/VideoGallery/utils';
2215

2316
const SearchSort = ({
2417
searchString,
2518
onSearchChange,
2619
clearSearchString,
2720
sortBy,
21+
sortKeys,
22+
sortMessages,
2823
onSortClick,
2924
filterBy,
3025
onFilterClick,
@@ -43,24 +38,26 @@ const SearchSort = ({
4338
autoFocus
4439
onChange={onSearchChange}
4540
placeholder={intl.formatMessage(messages.searchPlaceholder)}
46-
trailingElement={searchString
47-
? (
48-
<IconButton
49-
alt={intl.formatMessage(messages.clearSearch)}
50-
iconAs={Icon}
51-
invertColors
52-
isActive
53-
onClick={clearSearchString}
54-
size="sm"
55-
src={Close}
56-
/>
57-
)
58-
: <Icon src={Search} />}
41+
trailingElement={
42+
searchString
43+
? (
44+
<IconButton
45+
alt={intl.formatMessage(messages.clearSearch)}
46+
iconAs={Icon}
47+
invertColors
48+
isActive
49+
onClick={clearSearchString}
50+
size="sm"
51+
src={Close}
52+
/>
53+
)
54+
: <Icon src={Search} />
55+
}
5956
value={searchString}
6057
/>
6158
</Form.Group>
6259

63-
{!showSwitch && <ActionRow.Spacer />}
60+
{ !showSwitch && <ActionRow.Spacer /> }
6461
<SelectMenu variant="link" className="search-sort-menu">
6562
{Object.keys(sortKeys).map(key => (
6663
<MenuItem
@@ -71,34 +68,34 @@ const SearchSort = ({
7168
>
7269
<span className="search-sort-menu-by">
7370
<FormattedMessage {...messages.sortBy} />
74-
<span style={{ whiteSpace: 'pre-wrap' }}></span>
71+
<span style={{ whiteSpace: 'pre-wrap' }}> </span>
7572
</span>
7673
<FormattedMessage {...sortMessages[key]} />
7774
</MenuItem>
7875
))}
7976
</SelectMenu>
8077

81-
{onFilterClick && (
82-
<Dropdown>
83-
<Dropdown.Toggle
84-
data-testid="dropdown-filter"
85-
className="text-gray-700"
86-
id="gallery-filter-button"
87-
variant="tertiary"
88-
>
89-
<FormattedMessage {...filterMessages[filterBy]} />
90-
</Dropdown.Toggle>
91-
<Dropdown.Menu>
92-
{Object.keys(filterKeys).map(key => (
93-
<Dropdown.Item data-testid={`dropdown-filter-${key}`} key={key} onClick={onFilterClick(key)}>
94-
<FormattedMessage {...filterMessages[key]} />
95-
</Dropdown.Item>
96-
))}
97-
</Dropdown.Menu>
98-
</Dropdown>
78+
{ onFilterClick && (
79+
<Dropdown>
80+
<Dropdown.Toggle
81+
data-testid="dropdown-filter"
82+
className="text-gray-700"
83+
id="gallery-filter-button"
84+
variant="tertiary"
85+
>
86+
<FormattedMessage {...filterMessages[filterBy]} />
87+
</Dropdown.Toggle>
88+
<Dropdown.Menu>
89+
{Object.keys(filterKeys).map(key => (
90+
<Dropdown.Item data-testid={`dropdown-filter-${key}`} key={key} onClick={onFilterClick(key)}>
91+
<FormattedMessage {...filterMessages[key]} />
92+
</Dropdown.Item>
93+
))}
94+
</Dropdown.Menu>
95+
</Dropdown>
9996
)}
10097

101-
{showSwitch && (
98+
{ showSwitch && (
10299
<>
103100
<ActionRow.Spacer />
104101
<Form.SwitchSet
@@ -112,6 +109,7 @@ const SearchSort = ({
112109
</Form.SwitchSet>
113110
</>
114111
)}
112+
115113
</ActionRow>
116114
);
117115
};
@@ -135,6 +133,8 @@ SearchSort.propTypes = {
135133
onFilterClick: PropTypes.func,
136134
filterKeys: PropTypes.shape({}),
137135
filterMessages: PropTypes.shape({}),
136+
sortKeys: PropTypes.shape({}).isRequired,
137+
sortMessages: PropTypes.shape({}).isRequired,
138138
showSwitch: PropTypes.bool,
139139
switchMessage: PropTypes.shape({}).isRequired,
140140
onSwitchClick: PropTypes.func,

0 commit comments

Comments
 (0)