Skip to content

fix: remove update cycle from calendar#6633

Merged
GZolla merged 3 commits intomainfrom
gzolla/inspiration-calendar-updates
Mar 24, 2026
Merged

fix: remove update cycle from calendar#6633
GZolla merged 3 commits intomainfrom
gzolla/inspiration-calendar-updates

Conversation

@GZolla
Copy link
Copy Markdown
Contributor

@GZolla GZolla commented Feb 25, 2026

@GZolla GZolla requested a review from a team as a code owner February 25, 2026 19:01
@github-actions
Copy link
Copy Markdown
Contributor

Thanks for the PR! 🎉

We've deployed an automatic preview for this PR - you can see your changes here:

URL https://live.d2l.dev/prs/BrightspaceUI/core/pr-6633/

Note

The build needs to finish before your changes are deployed.
Changes to the PR will automatically update the instance.

);
if (dropdownContent) this._dialog = true;

this.addEventListener('blur', () => this._isInitialFocusDate = true);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Interesting... so just the fact that these event handlers were being wired up in firstUpdated was somehow causing an extra update cycle?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

They were not, the rest of the firstUpdate code was, so we could keep them on firstUpdated but it would be the only thing there. And anyways, I believe this fits better with the recommended pattern for lit event handling.

The examples on that page define internal listeners on the constructor but does not explicitly recommend that approach. It does however explicitly recommend that external listeners (e.g. for window or other components) would be defined on connectedCallback, so might as well define internal listeners here too.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Note: we have some best practices for this in the Daylight docs with explanation which I believe aligns with the Lit documentation.

While handlers on this can be managed from connected/disconnectedCallback, wiring up in that lifecycle method really just preferred when wiring up handlers to external elements. Wiring up to this in firstUpdated or the constructor simplifies managing it. There's the perf things too, but I think it is probably negligible.

Comment thread components/calendar/calendar.js Outdated

firstUpdated() {
super.firstUpdated();
this.removeEventListener('blur', this._onBlur.bind(this));
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Are these supposed to be adding the handlers instead?

@GZolla GZolla merged commit 9d95acf into main Mar 24, 2026
9 of 10 checks passed
@GZolla GZolla deleted the gzolla/inspiration-calendar-updates branch March 24, 2026 22:21
@d2l-github-release-tokens
Copy link
Copy Markdown

🎉 This PR is included in version 3.227.7 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants