Skip to content
New issue

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

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

Already on GitHub? # to your account

[PLAY-671] Adding classname prop to Typeahead kit #2373

Merged
merged 2 commits into from
Mar 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
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
8 changes: 7 additions & 1 deletion playbook/app/pb_kits/playbook/pb_typeahead/_typeahead.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import { noop, buildDataProps } from '../utilities/props'

type TypeaheadProps = {
async?: boolean,
className?: string,
components?: object,
createable?: boolean,
dark?: boolean,
Expand All @@ -49,6 +50,7 @@ type TypeaheadProps = {

const Typeahead = ({
async,
className,
components = {},
createable,
error = "",
Expand Down Expand Up @@ -111,8 +113,12 @@ const Typeahead = ({
}

const dataProps = buildDataProps(data)
const classes = classnames(
'pb_typeahead_kit react-select',
globalProps(props),
className
)

const classes = `pb_typeahead_kit react-select ${globalProps(props)}`
const inlineClass = selectProps.inline ? 'inline' : null

return (
Expand Down
15 changes: 15 additions & 0 deletions playbook/app/pb_kits/playbook/pb_typeahead/_typeahead.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -93,3 +93,18 @@ test('typeahead multi select with badges and small pills', () => {
expect(badge).toBeInTheDocument()
})

test('should pass className prop', () => {
const className = 'custom-class-name'
render(
<Typeahead
className={className}
data={{ testid: 'typeahead-test' }}
defaultValue={[options[0]]}
label="Colors"
options={options}
/>
)

const kit = screen.getByTestId('typeahead-test')
expect(kit).toHaveClass(className)
})