Skip to content

bug: ios, next and prev buttons do not work when calendar grid is only partially visible #27913

Closed

Description

@thomasmassmann

Prerequisites

Ionic Framework Version

v6.x, v7.x

Current Behavior

The arrow buttons on ion-datetime do not work on iOS devices (web, simulator, real device) when the calendar grid is only partially visible (less than 3 rows of days).

Bringing the calendar into the viewport (3 rows or more), the arrow buttons work again.

Expected Behavior

The arrow buttons to switch between months work, even when only the arrow buttons are currently in visible to the user.

Steps to Reproduce

  1. Open https://docs-demo.ionic.io/component/datetime
  2. Open one of the calendar widgets.
  3. Ensure the calendar is fully visible.
  4. The arrow buttons allow changing the month.
  5. Ensure only 2 rows of the calendar days are visible.
  6. Try to change the month (more than 2, either direction is fine).
  7. With the first click, the month selection stays at the current month, but the days grid slides in the next/previous month).
  8. Any additional click on the arrow button has no effect.

Code Reproduction URL

https://github.com/ionic-team/docs-demo

Ionic Info

[WARN] You are not in an Ionic project directory. Project context may be
       missing.

Ionic:

   Ionic CLI : 7.1.1

Utility:

   cordova-res : not installed globally
   native-run  : not installed globally

System:

   NodeJS : v18.16.0
   npm    : 9.5.1
   OS     : macOS Unknown

Additional Information

No response

Activity

  1. self-assigned this
    on Aug 2, 2023
  2. liamdebeasi commented on Aug 2, 2023

    @liamdebeasi
    Contributor

    Thanks for the report. The problem here is we get the month that is at the center of the datetime (on both x and y axes):

    const elementAtCenter = root.elementFromPoint(box.x + box.width / 2, box.y + box.height / 2);

    If the center of the datetime is out of view, then this call will return null. It's possible for either only the top or the bottom part of datetime to be visible, so we should account for this.

  3. added
    package: core
    type: bug
    on Aug 2, 2023
  4. liamdebeasi commented on Aug 2, 2023

    @liamdebeasi
    Contributor

    Here is a dev build if you are interested in testing the proposed fix:

    7.2.2-dev.11690987396.11ef134f
    

    Install Example:

    npm install @ionic/[email protected]
    
  5. thomasmassmann commented on Aug 2, 2023

    @thomasmassmann
    Author

    Hi @liamdebeasi , thanks for taking a look at this. I tried the dev version in a real world project and it still shows the same error.

  6. liamdebeasi commented on Aug 2, 2023

    @liamdebeasi
    Contributor

    Can you provide the sample project so I can test? I tested the dev build on the link provided in the original post, and it is now working as expected.

  7. removed their assignment
    on Aug 2, 2023
  8. thomasmassmann commented on Aug 2, 2023

    @thomasmassmann
    Author

    Here is an example: https://github.com/thomasmassmann/ionicCalendarIssue

    It is now working as long as a bit of 1 row with dates is visible. Only having the calendar header visible still results in the error.

    My real-world project has the calendar in a modal, and in there in an accordion. That is a different thing to solve now.

  9. liamdebeasi commented on Aug 2, 2023

    @liamdebeasi
    Contributor

    Thanks! Here is a new dev build if you would like to test:

    7.2.2-dev.11690996559.1019674a
    
  10. thomasmassmann commented on Aug 2, 2023

    @thomasmassmann
    Author

    Amazing!

  11. thomasmassmann commented on Aug 3, 2023

    @thomasmassmann
    Author

    Just to confirm, the latest release now also fixes the issues when an ion-datetime is embedded in an ion-accordion.

  12. liamdebeasi commented on Aug 3, 2023

    @liamdebeasi
    Contributor

    Great! I am going to keep this open until the linked PR is merged.

  13. added a commit that references this issue on Aug 4, 2023
    eb19c28
  14. liamdebeasi commented on Aug 4, 2023

    @liamdebeasi
    Contributor

    Thanks for the issue. This has been resolved via #27917, and a fix will be available in an upcoming release of Ionic Framework.

  15. ionitron-bot commented on Sep 3, 2023

    @ionitron-bot

    Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Ionic, please create a new issue and ensure the template is fully filled out.

  16. locked and limited conversation to collaborators on Sep 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    package: coretype: bug

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions