Skip to content

Calendar components: simplify types, forward all onChange arguments #103675

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

Merged
merged 4 commits into from
May 26, 2025

Conversation

ciampo
Copy link
Contributor

@ciampo ciampo commented May 23, 2025

Closes DS-232

Proposed Changes

  • Remove type unions around the required prop.
  • Forward onChange arguments in the useControlledValue hook

Why are these changes being made?

The current type unions complicate the code without necessarily bringing better DX. Removing them allows us to simplify the code, and generalize the useControlledValue hook.

The arguments forwarding for the onChange callback in useControlledValue also fixes an inconsistency, where the onSelect callback prop would return extra arguments only in uncontrolled mode.

Testing Instructions

  • No TS errors
  • DateCalendar and DateRangeCalendar works as expected in Storybook

Pre-merge Checklist

  • Has the general commit checklist been followed? (PCYsg-hS-p2)
  • Have you written new tests for your changes?
  • Have you tested the feature in Simple (P9HQHe-k8-p2), Atomic (P9HQHe-jW-p2), and self-hosted Jetpack sites (PCYsg-g6b-p2)?
  • Have you checked for TypeScript, React or other console errors?
  • Have you used memoizing on expensive computations? More info in Memoizing with create-selector and Using memoizing selectors and Our Approach to Data
  • Have we added the "[Status] String Freeze" label as soon as any new strings were ready for translation (p4TIVU-5Jq-p2)?
    • For UI changes, have we tested the change in various languages (for example, ES, PT, FR, or DE)? The length of text and words vary significantly between languages.
  • For changes affecting Jetpack: Have we added the "[Status] Needs Privacy Updates" label if this pull request changes what data or activity we track or use (p4TIVU-aUh-p2)?

Copy link

github-actions bot commented May 23, 2025

@matticbot
Copy link
Contributor

matticbot commented May 23, 2025

This PR modifies the release build for the following Calypso Apps:

For info about this notification, see here: PCYsg-OT6-p2

  • help-center

To test WordPress.com changes, run install-plugin.sh $pluginSlug feat/calendar-simplify-types on your sandbox.

@matticbot
Copy link
Contributor

This PR does not affect the size of JS and CSS bundles shipped to the user's browser.

Generated by performance advisor bot at iscalypsofastyet.com.

@ciampo ciampo self-assigned this May 23, 2025
@ciampo ciampo added [Type] Enhancement Changes to an existing feature — removing, adding, or changing parts of it Components labels May 23, 2025
@ciampo ciampo changed the title Feat/calendar simplify types Calendar components: simplify types, forward all onChange arguments May 23, 2025
@ciampo ciampo marked this pull request as ready for review May 23, 2025 15:31
@ciampo ciampo requested a review from a team as a code owner May 23, 2025 15:31
@matticbot matticbot added the [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. label May 23, 2025
@ciampo ciampo requested review from mirka and aduth May 23, 2025 15:31
@ciampo ciampo mentioned this pull request May 23, 2025
8 tasks
@ciampo ciampo force-pushed the feat/calendar-simplify-types branch from 14bf8d6 to 57c9895 Compare May 26, 2025 13:14
Copy link
Member

@tyxla tyxla left a comment

Choose a reason for hiding this comment

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

LGTM, thanks for the cleanup 👍

Comment on lines 142 to 143
* console.log("Selected:", selected);
* console.log("Triggered by:", triggerDate);
Copy link
Member

Choose a reason for hiding this comment

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

Nit: do we care about WP-style spacing in these kinds of examples?

@ciampo ciampo force-pushed the feat/calendar-simplify-types branch from 57c9895 to 1c3decc Compare May 26, 2025 15:07
@ciampo
Copy link
Contributor Author

ciampo commented May 26, 2025

E2E can't be caused by the changes in this PR since they are not exported from the package (and used anywhere)

@ciampo ciampo merged commit f516ae8 into trunk May 26, 2025
9 of 11 checks passed
@ciampo ciampo deleted the feat/calendar-simplify-types branch May 26, 2025 15:24
@github-actions github-actions bot removed the [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. label May 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Components [Type] Enhancement Changes to an existing feature — removing, adding, or changing parts of it
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants