Skip to content

bug: ion-datetime-button: when clicking datetime-button a second time, date is not selected and previous month buttons does not work. #31155

Closed

Description

@shinkhouse

Prerequisites

Ionic Framework Version

v8.x

Current Behavior

When clicking ion-datetime-button a second time, date is not selected and previous month buttons does not work.

Expected Behavior

When a value has been set the first time and we open ion-datetime-button again, the date should still be selected and the previous and next month buttons should work properly.

Steps to Reproduce

  1. Go to https://ionicframework.com/docs/api/datetime-button#basic-usage and go to Basic usage.
  2. Click on the date button and select a date and confirm or tap outside picker.
  3. Click on date button a second time, date will no longer be selected and previous month < button will not work.

Code Reproduction URL

https://stackblitz.com/edit/8ba5snu3?file=index.html

Ionic Info

(This is from your own StackBlitz link, ionic info is not installed, but here is the package.json)
{
"name": "html-starter",
"private": true,
"type": "module",
"main": "index.ts",
"scripts": {
"dev": "vite",
"build": "vite build",
"start": "vite preview"
},
"dependencies": {
"@ionic/core": "8.8.7",
"ionicons": "8.0.13"
},
"devDependencies": {
"typescript": "~5.9.0",
"vite": "^8.0.0",
"vite-plugin-static-copy": "^4.0.0"
}
}

Additional Information

Screen.Recording.2026-05-19.at.11.20.57.AM.mov

Activity

  1. r345on commented on Jun 11, 2026

    @r345on

    @shinkhouse I can suggest a workaround for now, until @IonicTeam solves this issue. Set min value for ion-datetime during initialization and unset it afterwards.

    import { Component } from '@angular/core';
    
    @Component({
    	selector: 'datetime-test',
    	template: `
    		<ion-datetime-button datetime="datetime"></ion-datetime-button>
    		<ion-modal
    			[keepContentsMounted]="true"
    			(ionModalWillPresent)="setDatetimeMin($event)">
    			<ng-template>
    				<ion-datetime id="datetime"></ion-datetime>
    			</ng-template>
    		</ion-modal>`,
    	styles: [`:host {
    		display: flex;
    		align-items: center;
    		justify-content: center;
    		height: 100%;
    	}`],
    	standalone: false
    })
    export class DatetimeTestComponent {
    
    	private readonly currentMonthISO: string;
    
    	constructor() {
    		const date = new Date();
    		const timezoneOffset = date.getTimezoneOffset() * 60000;
    		const localISO = new Date(date.getTime() - timezoneOffset).toISOString();
    		this.currentMonthISO = localISO.slice(0, 7);
    	}
    
    	protected setDatetimeMin(event: CustomEvent) {
    		const modal = event.target;
    		const datetime = (modal as HTMLElement).querySelector('ion-datetime');
    		if (datetime) {
    			datetime.min = datetime.value ? (datetime.value as string).slice(0, 7) : this.currentMonthISO;
    			setTimeout(() => datetime.min = undefined, 0);
    		}
    	}
    }
    
  2. added theissue type on Aug 6, 2026
  3. added a commit that references this issue on Aug 7, 2026
    d59e341
  4. ShaneK commented on Aug 12, 2026

    @ShaneK
    Member

    Thanks for highlighting this issue, this is fixed now as part of v8.8.18!

  5. ionitron-bot commented on Sep 11, 2026

    @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.

  6. locked and limited conversation to collaborators on Sep 11, 2026
  7. added a commit that references this issue on Oct 3, 2026
    d8d2a5f
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

    type: buga confirmed bug report

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions