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

Bugfix/button loading issue in modal #3252

Merged
merged 20 commits into from
Dec 20, 2024

Conversation

it-vegard
Copy link
Contributor

@it-vegard it-vegard commented Oct 18, 2024

Description

Fix edge-case issue with setting loading={true} on a Button in a Modal on page load. (Why would anyone do this?)

Button would get width: 0 because the width is calculated before the button is rendered.
This also caused the spinner not to show, because we checked widthOverride instead of the loading prop.

Component Checklist 📝

  • JSDoc
  • Examples
  • Documentation
  • Storybook
  • Style mappings (@navikt/core/css/config/_mappings.js)
  • Component tokens (@navikt/core/css/tokens.json)
  • CSS class deprecations (@navikt/aksel-stylelint/src/deprecations.ts)
  • Exports (@navikt/core/react/src/index.ts and @navikt/core/react/package.json)
  • New component? CSS import (@navikt/core/css/index.css)
  • Breaking change? Update migration guide. Consider codemod.
  • Changeset (Format: <Component>: <gitmoji?> <Text>. E.g. "Button: ✨ Add feature xyz.")

Making this change because widthOverride sometimes gets set to 0 (should also be fixed), meaning this check fails as "falsy".
…odals

Checking that width is truthy (not zero) will avoid issue where widthOverride gets set to 0 because the button is not yet rendered.
Copy link

changeset-bot bot commented Oct 18, 2024

🦋 Changeset detected

Latest commit: ce25ccd

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 7 packages
Name Type
@navikt/ds-react Patch
@navikt/ds-css Patch
@navikt/ds-tokens Patch
@navikt/ds-tailwind Patch
@navikt/aksel-icons Patch
@navikt/aksel Patch
@navikt/aksel-stylelint Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link
Contributor

github-actions bot commented Oct 18, 2024

Storybook demo / Chromatic

68b13d5a9 | 91 components | 135 stories

@JulianNymark
Copy link
Contributor

looks good to me! I added a story for testing this (i also tried the same story on main to see that it breaks there, but is fixed here 🎉 )

on main (broken loading buttons inside modal ):
image

this branch:
image

:shipit:

JulianNymark
JulianNymark previously approved these changes Dec 19, 2024
Copy link
Contributor

@HalvorHaugan HalvorHaugan left a comment

Choose a reason for hiding this comment

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

I dispute the approval since this hasn't been fixed yet 😅

@navikt/core/css/button.css Outdated Show resolved Hide resolved
@navikt/core/react/src/button/Button.tsx Outdated Show resolved Hide resolved
@navikt/core/css/button.css Show resolved Hide resolved
it-vegard and others added 3 commits December 19, 2024 15:30
…ly child (hidden), because of the loader icon. Instead checks for no label.

Could consider :not(:has(:is(.navds-button__icon, .navds-loader))) as well, to be more robust, but it might be overkill.
Copy link
Contributor

Choose a reason for hiding this comment

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

Now the only thing left is to update button.darkside.css as well 😁

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I was about to comment that. 🙈

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added a quick edit for darkside. I'll welcome suggested improvements, e.g. for nesting choices.

Copy link
Contributor

@JulianNymark JulianNymark left a comment

Choose a reason for hiding this comment

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

or wait, unapprove since darkside.css isn't done yet? (as mentioned)

Copy link
Contributor

@HalvorHaugan HalvorHaugan left a comment

Choose a reason for hiding this comment

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

LGTM

@it-vegard it-vegard merged commit 443b129 into main Dec 20, 2024
4 checks passed
@it-vegard it-vegard deleted the bugfix/button-loading-issue-in-modal branch December 20, 2024 09:44
@github-actions github-actions bot mentioned this pull request Dec 20, 2024
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