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

[EuiButton] Fix overridden (instead of merged) className #6887

Merged
merged 3 commits into from
Jun 29, 2023
Merged
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
14 changes: 11 additions & 3 deletions src/components/button/button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
*/

import React, { FunctionComponent, Ref, ReactNode } from 'react';
import classNames from 'classnames';

import {
CommonProps,
Expand Down Expand Up @@ -84,7 +85,13 @@ export type Props = ExclusiveUnion<
* and the logic for element-specific attributes
*/
export const EuiButton: FunctionComponent<Props> = (props) => {
const { buttonRef, color: _color = 'primary', fill, ...rest } = props;
const {
className,
buttonRef,
color: _color = 'primary',
fill,
...rest
} = props;

const buttonIsDisabled = isButtonDisabled({
href: rest.href,
Expand All @@ -100,6 +107,7 @@ export const EuiButton: FunctionComponent<Props> = (props) => {

const buttonFocusStyle = useEuiButtonFocusCSS();

const classes = classNames('euiButton', className);
const cssStyles = [buttonColorStyles, buttonFocusStyle];

if (_color === 'ghost') {
Expand All @@ -113,9 +121,9 @@ export const EuiButton: FunctionComponent<Props> = (props) => {

return (
<EuiButtonDisplay
className="euiButton"
ref={buttonRef}
Comment on lines -116 to -117
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Super interesting. I never noticed this!

className={classes}
css={cssStyles}
ref={buttonRef}
{...rest}
/>
);
Expand Down