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): loading is disabled #7830

Merged
merged 1 commit into from
Oct 28, 2024
Merged
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
15 changes: 8 additions & 7 deletions packages/vkui/src/components/Button/Button.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@
border-radius: var(--vkui--size_border_radius_rounded--regular);
}

.loading {
cursor: progress;
.loading:not(.disabled) {
/* stylelint-disable-next-line declaration-no-important -- перебиваем disabled из Clickable */
cursor: progress !important;
}

.singleIcon {
Expand Down Expand Up @@ -67,14 +68,14 @@
text-align: end;
}

.host[disabled] {
.disabled {
opacity: var(--vkui--opacity_disable);
}

.modePrimary[disabled]:not(.appearanceOverlay):not(.appearanceNegative):not(.appearancePositive),
.modeSecondary[disabled]:not(.appearanceOverlay),
.modeTertiary[disabled]:not(.appearanceOverlay),
.modeOutline[disabled]:not(.appearanceOverlay) {
.modePrimary.disabled:not(.appearanceOverlay):not(.appearanceNegative):not(.appearancePositive),
.modeSecondary.disabled:not(.appearanceOverlay),
.modeTertiary.disabled:not(.appearanceOverlay),
.modeOutline.disabled:not(.appearanceOverlay) {
opacity: 0.64;
}

Expand Down
3 changes: 3 additions & 0 deletions packages/vkui/src/components/Button/Button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ export const Button = ({
className,
disableSpinnerAnimation,
rounded,
disabled,
...restProps
}: ButtonProps): React.ReactNode => {
const hasIcons = Boolean(before || after);
Expand All @@ -90,6 +91,7 @@ export const Button = ({
activeMode={styles.active}
Component={restProps.href ? 'a' : 'button'}
focusVisibleMode="outside"
disabled={loading || disabled}
{...restProps}
onClick={loading ? undefined : onClick}
className={classNames(
Expand All @@ -106,6 +108,7 @@ export const Button = ({
hasIconOnly && !stretched && styles.singleIcon,
loading && styles.loading,
rounded && styles.rounded,
disabled && styles.disabled,
)}
getRootRef={getRootRef}
>
Expand Down
Loading