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(atom/button): avoid following the link if link button is disabled #871

Merged
merged 1 commit into from
Nov 14, 2019

Conversation

oriolpuig
Copy link
Collaborator

Issue (#387):
If an atom-button type link is disabled, the link still works.

Expected behavior:
If an atom-button type link is disabled, the link shouldn't work.

Solution:
We can prevent the link navigation using the disabled prop of the atom-button.

@@ -17,7 +17,7 @@ const Button = ({
return link ? (
<Link
{...attrs}
href={href}
href={!disabled && href}
Copy link
Contributor

Choose a reason for hiding this comment

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

Corrigeme si me equivoco pero si disabled es false el valor de la prop href seria false?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

No, si disabled=false el resultado de la condición será true y, por tanto, el atributo href tendrá el valor de la propiedad href

Copy link
Member

Choose a reason for hiding this comment

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

Pero cuando disabled es true la prop href tendrá valor false. El enlace del componente tendrá href=false?

Copy link
Contributor

Choose a reason for hiding this comment

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

Cuando la prop href es false, el atributo no existirá.

Copy link
Contributor

Choose a reason for hiding this comment

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

merci. Me lian a veces los short circuits

Copy link
Member

Choose a reason for hiding this comment

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

Perfecto! Gracias

@oriolpuig oriolpuig merged commit 96157f7 into master Nov 14, 2019
@oriolpuig oriolpuig deleted the fix/atom-button-link-disabled branch November 14, 2019 09:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants