Skip to content

Commit

Permalink
fix: tasks on timeline not adjusting to zoom
Browse files Browse the repository at this point in the history
There are issues in svelte with cascading dependencies
in reactive declarations, from what I understand.
Since `background color` relies on `$store.timelineColored`,
having `textColor` rely on both seemed to cause issues.
Removing the direct dependency of the store works,
anyway.
  • Loading branch information
JosephBrooksbank authored and ivan-lednev committed Sep 7, 2023
1 parent de53492 commit 61de9a2
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/ui/components/task.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
: "var(--background-primary)";
let properContrastColors: IContrastColors;
$: properContrastColors = $settings.timelineColored && planItem.startTime
$: properContrastColors = backgroundColor.startsWith("#") && planItem.startTime
? getTextColorWithEnoughContrast(backgroundColor)
: {
normal: "var(--text-normal)",
Expand Down

3 comments on commit 61de9a2

@lukemt
Copy link

@lukemt lukemt commented on 61de9a2 Sep 7, 2023

Choose a reason for hiding this comment

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

I only worked on very small projects with svelte. I do love it, but I've seen those weird problems with these reactive dependencies that no-one can really explain, quite a few times out there 🤷‍♂️

@ivan-lednev
Copy link
Owner

Choose a reason for hiding this comment

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

I only worked on very small projects with svelte. I do love it, but I've seen those weird problems with these reactive dependencies that no-one can really explain, quite a few times out there 🤷‍♂️

Hey, @lukemt,

This is not a problem with reactive declarations, it looks like a compiler bug, that I've reported here: sveltejs/svelte#9185

The issues you're referring to usually arise in cases when people update an upstream reactive variable in a downstream reactive statement. People hope this will trigger another update cycle, but Svelte stops after the first cycle. This behavior is intended. Here is a great explanation from a Svelte dev: sveltejs/svelte#5848 (comment)

Derived stores don't have those limitations and they behave more predictably, BTW.

@lukemt
Copy link

@lukemt lukemt commented on 61de9a2 Sep 7, 2023

Choose a reason for hiding this comment

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

Yes, I think this describes it aptly! Thanks for the info!

Please sign in to comment.