Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(search-bar): cleaned up props #4923

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 24 additions & 14 deletions packages/ibm-products/src/components/SearchBar/SearchBar.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,12 @@
labelText,
onChange = defaults.onChange,
onSubmit = defaults.onSubmit,
placeHolderText,
placeholderText,
scopes = defaults.scopes,
scopesTypeLabel,
scopeToString,
selectedScopes = defaults.selectedScopes,
sortItems,

Check failure on line 54 in packages/ibm-products/src/components/SearchBar/SearchBar.js

View workflow job for this annotation

GitHub Actions / lint

'sortItems' is defined but never used. Allowed unused args must match /^_/u
submitLabel,
translateWithId,
value,
Expand Down Expand Up @@ -116,6 +116,15 @@
onChange(eventObject);
};

const multiSelectProps = {
label: scopesTypeLabel,
initialSelectedItems: selectedScopes,
items: scopes,
itemToString: scopeToString,
translateWithId,
...rest
IgnacioBecerra marked this conversation as resolved.
Show resolved Hide resolved
}

return (
<form
{...rest}
Expand All @@ -128,16 +137,11 @@
>
{scopes?.length ? (
<MultiSelect
{...multiSelectProps}
id={`${blockClass}__multi-select`}
name="search-scopes"
className={`${blockClass}__scopes`}
label={scopesTypeLabel}
onChange={handleSearchScopeChange}
initialSelectedItems={selectedScopes}
items={scopes}
itemToString={scopeToString}
translateWithId={translateWithId}
sortItems={sortItems}
size="lg"
/>
) : null}
Expand All @@ -147,7 +151,7 @@
labelText={labelText || ''}
name="search-input"
onChange={handleInputChange}
placeholder={placeHolderText}
placeholder={placeholderText}
value={text}
size="lg"
/>
Expand Down Expand Up @@ -187,6 +191,15 @@
return PropTypes.string(props, propName, componentName, ...rest);
};

export const deprecatedProps = {
/**
* **Deprecated**
*
* Provide accessible label text for the scopes MultiSelect.
*/
titleText: PropTypes.string,
};

// The types and DocGen commentary for the component props,
// in alphabetical order (for consistency).
// See https://www.npmjs.com/package/prop-types#usage.
Expand All @@ -212,7 +225,7 @@
onSubmit: PropTypes.func,

/** @type {string} Placeholder text to be displayed in the search input. */
placeHolderText: PropTypes.string.isRequired,
placeholderText: PropTypes.string.isRequired,

/** @type {Function} Function to get the text for each scope to display in dropdown. */
scopeToString: PropTypes.func,
Expand Down Expand Up @@ -241,14 +254,11 @@
/** @type {string} The label text for the search submit button. */
submitLabel: PropTypes.string.isRequired,

/**
* Provide accessible label text for the scopes MultiSelect.
*/
titleText: PropTypes.string,

/** @type {func} Callback function for translating MultiSelect's child ListBoxMenuIcon SVG title. */
translateWithId: PropTypes.func, // eslint-disable-line react/require-default-props

/** @type {string} Search query value. */
value: PropTypes.string,

...deprecatedProps,
};
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ const scopes = [

const defaultProps = {
clearButtonLabelText: 'Clear',
placeHolderText: 'Search...',
placeholderText: 'Search...',
submitLabel: 'Search',
onChange: (newVal) => action('onChange')(newVal),
onSubmit: (newVal) => action('onSubmit')(newVal),
Expand Down
Loading