feat(toolbar-buttons) Add optional background color (#13691)

This commit is contained in:
Horatiu Muresan
2023-08-10 16:30:14 +03:00
committed by GitHub
parent 85fb7513db
commit 91de33550d
8 changed files with 41 additions and 7 deletions

View File

@@ -16,6 +16,11 @@ export interface IProps {
*/
accessibilityLabel: string;
/**
* The context menu item background color.
*/
backgroundColor?: string;
/**
* Component children.
*/
@@ -163,6 +168,7 @@ const useStyles = makeStyles()(theme => {
const ContextMenuItem = ({
accessibilityLabel,
backgroundColor,
children,
className,
controls,
@@ -181,7 +187,7 @@ const ContextMenuItem = ({
textClassName }: IProps) => {
const { classes: styles, cx } = useStyles();
const _overflowDrawer: boolean = useSelector(showOverflowDrawer);
const style = backgroundColor ? { backgroundColor } : {};
const onKeyPressHandler = useCallback(e => {
// only trigger the fallback behavior (onClick) if we dont have any explicit keyboard event handler
if (onClick && !onKeyPress && !onKeyDown && (e.key === 'Enter' || e.key === ' ')) {
@@ -223,6 +229,7 @@ const ContextMenuItem = ({
onKeyDown = { disabled ? undefined : onKeyDown }
onKeyPress = { disabled ? undefined : onKeyPressHandler }
role = { onClick ? role : undefined }
style = { style }
tabIndex = { onClick ? tabIndex : undefined }>
{customIcon ? customIcon
: icon && <Icon