Skip to content

Commit

Permalink
fix(Button): loading is disabled (#7830)
Browse files Browse the repository at this point in the history
- Fixes #7663
  • Loading branch information
SevereCloud authored Oct 28, 2024
1 parent 6fda214 commit 80116e3
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
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

0 comments on commit 80116e3

Please sign in to comment.