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

Download button may stay disabled even after logging in #28

Closed
Niklas20114552 opened this issue Jan 11, 2025 · 3 comments
Closed

Download button may stay disabled even after logging in #28

Niklas20114552 opened this issue Jan 11, 2025 · 3 comments
Labels
good first issue Good for newcomers

Comments

@Niklas20114552
Copy link

Niklas20114552 commented Jan 11, 2025

I was trying to download a song, but the Button was disabled although I was logged in.
As an enhancement it would be good to display why you can't download the song (like the tooltip that says you need to be logged in).

grafik

Edit: I thought that the Button was disabled, because my Account has to exist for some amount of time or due to a specific licence. I didn't realized, that the button being disabled is a bug.

@Niklas20114552
Copy link
Author

And now the download button is suddenly clickable. As I said, would be good to explain that.

grafik
Left: my old tab. Right: my new tab

@Bentroen Bentroen changed the title Explain why the Download-Button is disabled Download button may stay disabled even after logging in Jan 11, 2025
@tomast1337
Copy link
Member

This may be because the state of the DownloadButton is not controlled by React, so a proper re-render when it is enabled does not occur. Here is the DownloadButton's code:

const DownloadButton = ({
downloadCount,
handleClick,
}: {
downloadCount: number;
handleClick: React.MouseEventHandler<HTMLButtonElement>;
}) => {
let isLoggedIn = true;
try {
getTokenLocal();
} catch {
isLoggedIn = false;
}
return (
<div className='flex gap-0.5'>
<Tooltip>
<TooltipTrigger asChild>
<button
onClick={handleClick}
className='uppercase px-2 py-1 h-fit rounded-md text-sm bg-green-600 hover:enabled:bg-green-500 disabled:opacity-50'
disabled={!isLoggedIn}
>
<div className='flex flex-row items-center gap-2'>
<FontAwesomeIcon icon={faDownload} />
<div>Download</div>
</div>
</button>
</TooltipTrigger>
{!isLoggedIn && (
<TooltipContent>
{'You must sign in to download this song!'}
</TooltipContent>
)}
</Tooltip>
<CountBalloon count={downloadCount} />
</div>
);
};

By using useState to control the isLoggedIn state, this issue can be resolved. Feel free to send a PR with the solution if you'd like.

@tomast1337 tomast1337 added the good first issue Good for newcomers label Jan 17, 2025
@qsef1256
Copy link

This issue is still occurring.

Image

@tomast1337 tomast1337 reopened this Jan 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

3 participants