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

Fix HeaderButton endIcon styles #2369

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
5 changes: 5 additions & 0 deletions .changeset/nice-seas-explode.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@itwin/itwinui-react': patch
---

`HeaderButton`'s `endIcon` now properly gets the necessary default styles (e.g. fill color) and accessibility properties.
13 changes: 11 additions & 2 deletions packages/itwinui-react/src/core/Header/HeaderBasicButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@
*--------------------------------------------------------------------------------------------*/
import cx from 'classnames';
import * as React from 'react';
import { ButtonBase } from '../../utils/index.js';
import { ButtonBase, cloneElementWithRef } from '../../utils/index.js';
import type { PolymorphicForwardRefComponent } from '../../utils/index.js';
import type { ButtonProps } from '../Buttons/Button.js';
import { styles } from '../../styles.js';

export const HeaderBasicButton = React.forwardRef((props, ref) => {
const { className, children, startIcon, endIcon, styleType, size, ...rest } =
Expand All @@ -22,7 +23,15 @@ export const HeaderBasicButton = React.forwardRef((props, ref) => {
>
{startIcon}
{children}
{endIcon}
{!!endIcon
? cloneElementWithRef(endIcon, () => ({
className: cx(
styles['iui-header-breadcrumb-button-dropdown-icon'],
endIcon.props.className,
),
['aria-hidden']: true,
}))
: null}
</ButtonBase>
);
}) as PolymorphicForwardRefComponent<'button', ButtonProps>;
Original file line number Diff line number Diff line change
Expand Up @@ -39,19 +39,7 @@ export const HeaderDropdownButton = React.forwardRef((props, ref) => {
className={cx('iui-header-breadcrumb-button', className)}
ref={refs}
aria-label='Dropdown'
endIcon={
isMenuOpen ? (
<SvgCaretUpSmall
className='iui-header-breadcrumb-button-dropdown-icon'
aria-hidden
/>
) : (
<SvgCaretDownSmall
className='iui-header-breadcrumb-button-dropdown-icon'
aria-hidden
/>
)
}
endIcon={isMenuOpen ? <SvgCaretUpSmall /> : <SvgCaretDownSmall />}
{...rest}
>
{children}
Expand Down
Loading