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: Button icon order and margin in rtl mode #48821

Merged
merged 5 commits into from
May 8, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2774,7 +2774,11 @@ exports[`renders components/button/demo/multiple.tsx extend context correctly 1`
</div>
`;

exports[`renders components/button/demo/multiple.tsx extend context correctly 2`] = `[]`;
exports[`renders components/button/demo/multiple.tsx extend context correctly 2`] = `
[
"Warning: findDOMNode is deprecated and will be removed in the next major release. Instead, add a ref directly to the element you want to reference. Learn more about using refs safely here: https://reactjs.org/link/strict-mode-find-node%s",
]
afc163 marked this conversation as resolved.
Show resolved Hide resolved
`;
afc163 marked this conversation as resolved.
Show resolved Hide resolved

exports[`renders components/button/demo/noSpace.tsx extend context correctly 1`] = `
<div
Expand Down
16 changes: 9 additions & 7 deletions components/button/button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -258,16 +258,18 @@ const InternalCompoundedButton = React.forwardRef<
const kids =
children || children === 0 ? spaceChildren(children, needInserted && mergedInsertSpace) : null;

const genButtonContent = (iconComponent: React.ReactNode, kidsComponent: React.ReactNode) => {
const isRTL = direction === 'rtl';
const iconFirst = (iconPosition === 'start' && !isRTL) || (iconPosition === 'end' && isRTL);
return (
const genButtonContent = (iconComponent: React.ReactNode, kidsComponent: React.ReactNode) =>
iconPosition === 'start' ? (
<>
{iconFirst ? iconComponent : kidsComponent}
{iconFirst ? kidsComponent : iconComponent}
{iconComponent}
{kidsComponent}
</>
) : (
<>
{kidsComponent}
{iconComponent}
crazyair marked this conversation as resolved.
Show resolved Hide resolved
</>
);
};

if (linkButtonRestProps.href !== undefined) {
return wrapCSSVar(
Expand Down