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

fix the bug that disabled date becomes central date #2361

Merged
merged 6 commits into from
Sep 16, 2024

Conversation

ryubro
Copy link
Contributor

@ryubro ryubro commented Sep 6, 2024

What I did

  1. Add back the logic that checks the central date is available (removed from this PR: fix(calendar): focusable disabled dates #1978
  2. Call this.__calculateInitialCentralDate() and this.__createData() in firstUpdated instead of connectedCallback because props (like minDate) are not assigned yet when connectedCallback is called.
  3. Fix a few exisitng tests (check more details on the line comments)

Copy link

changeset-bot bot commented Sep 6, 2024

🦋 Changeset detected

Latest commit: 65d11f9

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

This PR includes changesets to release 1 package
Name Type
@lion/ui 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

@ryubro ryubro marked this pull request as ready for review September 6, 2024 12:39
@gerjanvangeest
Copy link
Member

@ryubro can you add a changeset, and fix the failing tests?

@@ -573,7 +572,7 @@ describe('<lion-calendar>', () => {
.disableDates="${/** @param {Date} d */ d => d.getDate() === 15}"
></lion-calendar>
`);
el.focusDate(el.findNearestEnabledDate());
el.focusDate(el.findNearestEnabledDate(new Date()));
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Without any argument findNearestEnabledDate uses the centralDate which is today by default, but after the PR, the initial centralDate moves to the nearest enabled date if today is disabled. Hence we're supplying explicitly today as the argument.

expect(isSameDate(el.centralDate, new Date('2019/06/03')), 'central date').to.be.true;
expect(isSameDate(elSetting.centralDate, new Date('2019/07/03')), 'central date').to.be
.true;
expect(isSameDate(el.centralDate, new Date('2019/07/03'))).to.be.true;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

After the PR, the central date would be nearest enabled date instead of today even when the date is disabled, which is the desired behavior, I believe.

@ryubro ryubro merged commit bb1f347 into master Sep 16, 2024
7 checks passed
@ryubro ryubro deleted the fix/datepicker-central-date branch September 16, 2024 09:12
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.

2 participants