@ionic/core 7.6.6-dev.11705526292.1bc0acb5 → 7.6.6-dev.11705595500.109bc77e

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -689,22 +689,41 @@ const Datetime = /*@__PURE__*/ proxyCustomElement(class Datetime extends HTMLEle
689
689
  const didChangeMonth = (month !== undefined && month !== workingParts.month) || (year !== undefined && year !== workingParts.year);
690
690
  const bodyIsVisible = el.classList.contains('datetime-ready');
691
691
  const { isGridStyle, showMonthAndYear } = this;
692
- if (isGridStyle && didChangeMonth && bodyIsVisible && !showMonthAndYear) {
693
- this.animateToDate(targetValue);
692
+ let areAllSelectedDatesInSameMonth = true;
693
+ if (Array.isArray(valueToProcess)) {
694
+ const firstMonth = valueToProcess[0].month;
695
+ for (const date of valueToProcess) {
696
+ if (date.month !== firstMonth) {
697
+ areAllSelectedDatesInSameMonth = false;
698
+ break;
699
+ }
700
+ }
694
701
  }
695
- else {
696
- /**
697
- * We only need to do this if we didn't just animate to a new month,
698
- * since that calls prevMonth/nextMonth which calls setWorkingParts for us.
699
- */
700
- this.setWorkingParts({
701
- month,
702
- day,
703
- year,
704
- hour,
705
- minute,
706
- ampm,
707
- });
702
+ /**
703
+ * If there is more than one date selected
704
+ * and the dates aren't all in the same month,
705
+ * then we should neither animate to the date
706
+ * nor update the working parts because we do
707
+ * not know which date the user wants to view.
708
+ */
709
+ if (areAllSelectedDatesInSameMonth) {
710
+ if (isGridStyle && didChangeMonth && bodyIsVisible && !showMonthAndYear) {
711
+ this.animateToDate(targetValue);
712
+ }
713
+ else {
714
+ /**
715
+ * We only need to do this if we didn't just animate to a new month,
716
+ * since that calls prevMonth/nextMonth which calls setWorkingParts for us.
717
+ */
718
+ this.setWorkingParts({
719
+ month,
720
+ day,
721
+ year,
722
+ hour,
723
+ minute,
724
+ ampm,
725
+ });
726
+ }
708
727
  }
709
728
  };
710
729
  this.animateToDate = async (targetValue) => {
@@ -688,22 +688,41 @@ const Datetime = class {
688
688
  const didChangeMonth = (month !== undefined && month !== workingParts.month) || (year !== undefined && year !== workingParts.year);
689
689
  const bodyIsVisible = el.classList.contains('datetime-ready');
690
690
  const { isGridStyle, showMonthAndYear } = this;
691
- if (isGridStyle && didChangeMonth && bodyIsVisible && !showMonthAndYear) {
692
- this.animateToDate(targetValue);
691
+ let areAllSelectedDatesInSameMonth = true;
692
+ if (Array.isArray(valueToProcess)) {
693
+ const firstMonth = valueToProcess[0].month;
694
+ for (const date of valueToProcess) {
695
+ if (date.month !== firstMonth) {
696
+ areAllSelectedDatesInSameMonth = false;
697
+ break;
698
+ }
699
+ }
693
700
  }
694
- else {
695
- /**
696
- * We only need to do this if we didn't just animate to a new month,
697
- * since that calls prevMonth/nextMonth which calls setWorkingParts for us.
698
- */
699
- this.setWorkingParts({
700
- month,
701
- day,
702
- year,
703
- hour,
704
- minute,
705
- ampm,
706
- });
701
+ /**
702
+ * If there is more than one date selected
703
+ * and the dates aren't all in the same month,
704
+ * then we should neither animate to the date
705
+ * nor update the working parts because we do
706
+ * not know which date the user wants to view.
707
+ */
708
+ if (areAllSelectedDatesInSameMonth) {
709
+ if (isGridStyle && didChangeMonth && bodyIsVisible && !showMonthAndYear) {
710
+ this.animateToDate(targetValue);
711
+ }
712
+ else {
713
+ /**
714
+ * We only need to do this if we didn't just animate to a new month,
715
+ * since that calls prevMonth/nextMonth which calls setWorkingParts for us.
716
+ */
717
+ this.setWorkingParts({
718
+ month,
719
+ day,
720
+ year,
721
+ hour,
722
+ minute,
723
+ ampm,
724
+ });
725
+ }
707
726
  }
708
727
  };
709
728
  this.animateToDate = async (targetValue) => {
@@ -526,22 +526,41 @@ export class Datetime {
526
526
  const didChangeMonth = (month !== undefined && month !== workingParts.month) || (year !== undefined && year !== workingParts.year);
527
527
  const bodyIsVisible = el.classList.contains('datetime-ready');
528
528
  const { isGridStyle, showMonthAndYear } = this;
529
- if (isGridStyle && didChangeMonth && bodyIsVisible && !showMonthAndYear) {
530
- this.animateToDate(targetValue);
529
+ let areAllSelectedDatesInSameMonth = true;
530
+ if (Array.isArray(valueToProcess)) {
531
+ const firstMonth = valueToProcess[0].month;
532
+ for (const date of valueToProcess) {
533
+ if (date.month !== firstMonth) {
534
+ areAllSelectedDatesInSameMonth = false;
535
+ break;
536
+ }
537
+ }
531
538
  }
532
- else {
533
- /**
534
- * We only need to do this if we didn't just animate to a new month,
535
- * since that calls prevMonth/nextMonth which calls setWorkingParts for us.
536
- */
537
- this.setWorkingParts({
538
- month,
539
- day,
540
- year,
541
- hour,
542
- minute,
543
- ampm,
544
- });
539
+ /**
540
+ * If there is more than one date selected
541
+ * and the dates aren't all in the same month,
542
+ * then we should neither animate to the date
543
+ * nor update the working parts because we do
544
+ * not know which date the user wants to view.
545
+ */
546
+ if (areAllSelectedDatesInSameMonth) {
547
+ if (isGridStyle && didChangeMonth && bodyIsVisible && !showMonthAndYear) {
548
+ this.animateToDate(targetValue);
549
+ }
550
+ else {
551
+ /**
552
+ * We only need to do this if we didn't just animate to a new month,
553
+ * since that calls prevMonth/nextMonth which calls setWorkingParts for us.
554
+ */
555
+ this.setWorkingParts({
556
+ month,
557
+ day,
558
+ year,
559
+ hour,
560
+ minute,
561
+ ampm,
562
+ });
563
+ }
545
564
  }
546
565
  };
547
566
  this.animateToDate = async (targetValue) => {
@@ -5,7 +5,7 @@ import { expect } from "@playwright/test";
5
5
  import { configs, test } from "../../../../utils/test/playwright/index";
6
6
  const SINGLE_DATE = '2022-06-01';
7
7
  const MULTIPLE_DATES = ['2022-06-01', '2022-06-02', '2022-06-03'];
8
- const MULTIPLE_DATES_SEPARATE_MONTHS = ['2022-04-01', '2022-05-01', '2022-06-01'];
8
+ const MULTIPLE_DATES_SEPARATE_MONTHS = ['2022-03-01', '2022-04-01', '2022-05-01'];
9
9
  class DatetimeMultipleFixture {
10
10
  constructor(page) {
11
11
  this.page = page;
@@ -118,10 +118,14 @@ configs({ modes: ['md'], directions: ['ltr'] }).forEach(({ title, config }) => {
118
118
  value: ['2022-06-01', '2022-06-02'],
119
119
  });
120
120
  });
121
- test('multiple default values across months should display at least one value', async () => {
122
- const datetime = await datetimeFixture.goto(config, MULTIPLE_DATES_SEPARATE_MONTHS);
121
+ test('should not scroll to new month when value is updated with dates in different months', async ({ page }) => {
122
+ const datetime = await datetimeFixture.goto(config, MULTIPLE_DATES);
123
+ await datetime.evaluate((el, dates) => {
124
+ el.value = dates;
125
+ }, MULTIPLE_DATES_SEPARATE_MONTHS);
126
+ await page.waitForChanges();
123
127
  const monthYear = datetime.locator('.calendar-month-year');
124
- await expect(monthYear).toHaveText(/April 2022/);
128
+ await expect(monthYear).toHaveText(/June 2022/);
125
129
  });
126
130
  test('with buttons, should only update value when confirm is called', async ({ page }) => {
127
131
  const datetime = await datetimeFixture.goto(config, SINGLE_DATE, { showDefaultButtons: true });
package/dist/docs.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "timestamp": "2024-01-17T21:20:06",
2
+ "timestamp": "2024-01-18T16:33:41",
3
3
  "compiler": {
4
4
  "name": "@stencil/core",
5
5
  "version": "4.10.0",
@@ -684,22 +684,41 @@ const Datetime = class {
684
684
  const didChangeMonth = (month !== undefined && month !== workingParts.month) || (year !== undefined && year !== workingParts.year);
685
685
  const bodyIsVisible = el.classList.contains('datetime-ready');
686
686
  const { isGridStyle, showMonthAndYear } = this;
687
- if (isGridStyle && didChangeMonth && bodyIsVisible && !showMonthAndYear) {
688
- this.animateToDate(targetValue);
687
+ let areAllSelectedDatesInSameMonth = true;
688
+ if (Array.isArray(valueToProcess)) {
689
+ const firstMonth = valueToProcess[0].month;
690
+ for (const date of valueToProcess) {
691
+ if (date.month !== firstMonth) {
692
+ areAllSelectedDatesInSameMonth = false;
693
+ break;
694
+ }
695
+ }
689
696
  }
690
- else {
691
- /**
692
- * We only need to do this if we didn't just animate to a new month,
693
- * since that calls prevMonth/nextMonth which calls setWorkingParts for us.
694
- */
695
- this.setWorkingParts({
696
- month,
697
- day,
698
- year,
699
- hour,
700
- minute,
701
- ampm,
702
- });
697
+ /**
698
+ * If there is more than one date selected
699
+ * and the dates aren't all in the same month,
700
+ * then we should neither animate to the date
701
+ * nor update the working parts because we do
702
+ * not know which date the user wants to view.
703
+ */
704
+ if (areAllSelectedDatesInSameMonth) {
705
+ if (isGridStyle && didChangeMonth && bodyIsVisible && !showMonthAndYear) {
706
+ this.animateToDate(targetValue);
707
+ }
708
+ else {
709
+ /**
710
+ * We only need to do this if we didn't just animate to a new month,
711
+ * since that calls prevMonth/nextMonth which calls setWorkingParts for us.
712
+ */
713
+ this.setWorkingParts({
714
+ month,
715
+ day,
716
+ year,
717
+ hour,
718
+ minute,
719
+ ampm,
720
+ });
721
+ }
703
722
  }
704
723
  };
705
724
  this.animateToDate = async (targetValue) => {