question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

feat: <IonDatetime> button position, or allow developers to control the datetime to require confirmation before triggering update

See original GitHub issue

Prerequisites

Describe the Feature Request

I like how the date picker when buttons are shown, requires confirmation before triggering the update, which enables a user to interact with the calendar, but unless triggering confirm, no update will actually happen.

However, this requires buttons to be enabled or exist. And positioning the buttons above for example is pretty simple, those can be rendered independently from the Ion-datetime, but you either get updates always now that there are no buttons, or you can trick the ion-datetime to think there are buttons but it still renders the padding around an empty element, which visually looks wrong.

Screen Shot 2022-08-17 at 12 25 57 PM

(I guess there is prolly a way to simply make it so that updates are ignored from the developer’s side, until some other trigger is made and interact directly with the instance of ion-datetime to do so.)

But I want to propose a request, would it make sense to adjust updating and controls to work like:

  • If the ion-datetime is rendering its default buttons, then treat things they way they work today. Only emit updates on confirm.
  • If the ion-datetime is rendering a slotted button, also treat it the same way today
  • But, if the developer wants full control around updates, maybe provide a prop called requireConfirmation
    • if true, events are only emit on confirm
    • if false, events are always emit, regardless of buttons being rendered or not
    • if undefined, the current behavior is good.

So this moves the component to operate under some typical defaults as it does today, but allows developers the option to show buttons and trigger updates always (for whatever reason). Or, show no buttons, but updates are triggered by the developer manually using the imperative API.

Describe the Use Case

Use case is to allow a developer total control over the rendering of confirmation buttons for date picking, by separating the announcement of updates from the visibility of buttons as a result of some blend of configuration. Instead, providing an explicit control prop around when updates should be announced.

Describe Preferred Solution

Something maybe like:

<button onClick={() => { this.ionDatetime.confirm() }}>Confirm</button>
<IonDatetime ref={this.ionDatetime} requireConfirmation />

Describe Alternatives

No response

Related Code

No response

Additional Information

No response

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
puopgcommented, Aug 18, 2022

Awesome, I can close this feature request then, as reading the value prop, basically allows me to build whatever version of this that I need. Thanks!

0reactions
ionitron-bot[bot]commented, Sep 17, 2022

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

ion-datetime - Ionic Framework
ion-datetime has confirm , cancel , and reset methods that developers can call when clicking on custom buttons. The reset method also allows...
Read more >
The New Datetime Component In Ionic - Ionic Blog
Let's take a look at the component and start to understand how it works. From Ionic v5 to v6. Before looking at what...
Read more >
Ionic 6 DateTime Modal Closes Background Modal
What is happening: When you open the datetime modal the value of the ion-datetime is set, this triggers the ionChange listener and the ......
Read more >
Ionic Framework VueJS - Working with Modal, Bottom Sheet ...
Posted on Oct 4, 2021 • Updated on Dec 29, 2021. Ionic Framework VueJS - Working with Modal, Bottom Sheet Drawer and DateTime...
Read more >
ionic/docs/core.json - UNPKG
Buttons without a role property will have the default look for the ... allowing developers to easily format datetime values within\nthe ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found