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

[Timeline]: Earliest date defaulted to current date when found date was later than current day #3458

Merged
merged 5 commits into from
Dec 16, 2024

Conversation

KenAJoh
Copy link
Collaborator

@KenAJoh KenAJoh commented Dec 13, 2024

Description

Resolves #3457

In short, if earliest date found was "1 jan 2027" and current date is "1 jan 2024" the returned date was "1 jan 2024". This was caused by the "default"-value in reduce being new Date()

Component Checklist 📝

  • JSDoc
  • Examples
  • Documentation / Decision Records
  • 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.")

Copy link

changeset-bot bot commented Dec 13, 2024

🦋 Changeset detected

Latest commit: f381fae

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 Dec 13, 2024

Storybook demo

603ccef14 | 91 komponenter | 135 stories

@navikt/core/react/src/timeline/hooks/useTimelineRows.ts Outdated Show resolved Hide resolved
);

return earliestDate;
}, [startDate, rows]);
Copy link
Contributor

Choose a reason for hiding this comment

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

The useMemo in useEarliestDate seems to be running on every render. I think it's because of rows. We can fix it later since it wasn't added in this PR, but I think we should reconsider all use of useMemo in this component.

Copy link
Contributor

@JulianNymark JulianNymark Dec 16, 2024

Choose a reason for hiding this comment

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

Is this potentially something that we can just delete entirely when we have upgraded to react 19 and decided to use the compiler... 🤔 (and the compiler should be able to optimise re-renders?)

Actually, I don't think it will make sense for a design system to "use the react compiler" (we wouldn't be able to use it on behalf of our consumers 😅 ), so nvm this.

HalvorHaugan
HalvorHaugan previously approved these changes Dec 16, 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.

Remember changeset!

@KenAJoh KenAJoh merged commit 6d6900c into main Dec 16, 2024
3 checks passed
@KenAJoh KenAJoh deleted the timeline-dates branch December 16, 2024 19:40
@github-actions github-actions bot mentioned this pull request Dec 16, 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.

[Innspill til komponent]: <Timeline />
3 participants