Skip to content

Commit

Permalink
feat: add classname prop to hover-menu-dropdown
Browse files Browse the repository at this point in the history
  • Loading branch information
HendrikThePendric committed Jan 24, 2024
1 parent 9ad9f35 commit 57eb703
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/components/Toolbar/HoverMenuBar/HoverMenuDropdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,13 @@ import React, { useRef } from 'react'
import menuButtonStyles from '../MenuButton.styles.js'
import { useHoverMenubarContext } from './HoverMenuBar.js'

export const HoverMenuDropdown = ({ children, label, dataTest, disabled }) => {
export const HoverMenuDropdown = ({
children,
className,
label,
dataTest,
disabled,
}) => {
const buttonRef = useRef()
const {
onDropDownButtonClick,
Expand All @@ -18,7 +24,7 @@ export const HoverMenuDropdown = ({ children, label, dataTest, disabled }) => {
return (
<>
<button
className={cx({ isOpen })}
className={cx(className, { isOpen })}
ref={buttonRef}
onClick={onDropDownButtonClick}
disabled={disabled}
Expand Down Expand Up @@ -46,6 +52,7 @@ HoverMenuDropdown.defaultProps = {
HoverMenuDropdown.propTypes = {
children: PropTypes.node.isRequired,
label: PropTypes.node.isRequired,
className: PropTypes.string,
dataTest: PropTypes.string,
disabled: PropTypes.bool,
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,15 @@ describe('<HoverMenuDropdown/>', () => {

expect(wrapper.find('button').prop('data-test')).toBe(dataTest)
})

it('accepts a `className` prop', () => {
const className = 'test'
const wrapper = shallow(
<HoverMenuDropdown label="test dropdown" className={className}>
children
</HoverMenuDropdown>
)

expect(wrapper.find('button')).toHaveClassName(className)
})
})

0 comments on commit 57eb703

Please sign in to comment.