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

feat(Search): add "placeholder" & documentation #4282

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
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ function SearchExampleStandard() {
<Grid.Column width={6}>
<Search
loading={loading}
placeholder='Search'
layershifter marked this conversation as resolved.
Show resolved Hide resolved
onResultSelect={(e, data) =>
dispatch({ type: 'UPDATE_SELECTION', selection: data.result.title })
}
Expand Down
3 changes: 3 additions & 0 deletions src/modules/Search/Search.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,9 @@ export interface StrictSearchProps {

/** A search can have different sizes. */
size?: 'mini' | 'tiny' | 'small' | 'large' | 'big' | 'huge' | 'massive'

/** A search can show placeholder text when empty. */
placeholder?: string
}

export interface SearchResultData extends SearchProps {
Expand Down
7 changes: 6 additions & 1 deletion src/modules/Search/Search.js
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ export default class Search extends Component {
// ----------------------------------------

renderSearchInput = (rest) => {
const { icon, input } = this.props
const { icon, input, placeholder } = this.props
const { value } = this.state

return Input.create(input, {
Expand All @@ -382,6 +382,7 @@ export default class Search extends Component {
onClick: this.handleInputClick,
tabIndex: '0',
value,
placeholder,
},
// Nested shorthand props need special treatment to survive the shallow merge
overrideProps: overrideSearchInputProps,
Expand Down Expand Up @@ -666,6 +667,9 @@ Search.propTypes = {

/** A search can have different sizes. */
size: PropTypes.oneOf(_.without(SUI.SIZES, 'medium')),

/** A search can show placeholder text when empty. */
placeholder: PropTypes.string,
}

Search.defaultProps = {
Expand All @@ -674,6 +678,7 @@ Search.defaultProps = {
minCharacters: 1,
noResultsMessage: 'No results found.',
showNoResults: true,
placeholder: '',
}

Search.autoControlledProps = ['open', 'value']
Expand Down