Problem/Motivation
As described in #3468866: UX optimizations to Date and Time entry fields, there is a common pattern in calendar software to show duration options in an overlay, to make it more obvious what end time will be created. As described by Jakob's Law of Usability, the use of familiar patterns improves user experience.
Here is how the interface currently looks, with the duration as a separate dropdown:

By contrast, here is an example of the Google Calendar interface:

Proposed resolution
Implement a similar pattern in the Smart Date widget. Ensure that the implementation includes keyboard navigation and other accessibility considerations.
Here is an example of how the Smart Date interface looks with the changes in the current MR:

| Comment | File | Size | Author |
|---|
Issue fork smart_date-3472863
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #3
mandclu commentedHere's a preview of how the updated widget looks, based on the MR

Comment #4
ckrina“there is a common pattern in calendar software to show duration options in an overlay” is not a good enough reason to merge this into Drupal CMS, just a good enough reason to test it and evaluate if we want it.
I'd love that, if possible UX or UI improvements are identified, we highlight them first and discuss them, before assuming they are correct and merging them. Because as a consequence you'll start building things on top of that, others reusing them, and then changing things will be a headache.
So I'd recommend not merging this, but first test it to make sure it's an improvement.
Comment #5
mandclu commentedBased on the discussions here and in Drupal slack, I'm going to update this to only use the new overlay if the site builder has opted into it in the formatter settings, and I will mark it as experimental
Comment #6
mandclu commentedComment #7
mandclu commentedHere's an updated look at how the overlay is formatted, now entirely with CSS, using separate spans for the duration and related end time.

Also, the changes won't be visible unless this new configuration is opted-into.

Comment #8
tirupati_singh commentedHi @mandclu, I've applied the provided MR as a patch and it applied cleanly with no errors. After applying the patch
Use an overlay to display duration options. - EXPERIMENTALoption is now being shown in smart_date field widget. When enabling the new overlay display duration, duration is shown between the time in the node edit page. However, there's a spacing/alignment issue in the overlay as shown in the attached screenshot. The extra spaces issue can be resolved ifwidth: 3.75rem;is removed from the class.smart-date--duration-list--time. After removing the extra space is not visible and the time duration is displayed properly. I've attached screenshots of before and after fixes for your reference. As the design issue is present hence moving the issue status to Needs work.Thanks!
Comment #9
mandclu commented@tirupati_singh Thank you for the feedback. The challenge underlying your feedback is that this widget needs to accommodate parts of the world that display time in a 12-hour format (e.g. 8:47pm) and the more widely used 24-hour format (e.g. 20:47). You can probably guess which of these I typically use ;-)
I believe the code can be updated to accommodate both properly. I can work on this.
Comment #10
mandclu commentedThe updated MR should only apply the 12h formatting (notably, the wider width) if needed. Please test.
Comment #11
tirupati_singh commentedHi @mandclu, now I can confirm that the styling issue for the duration has been fixed. I've tested the overlay duration for both 12h and 24h formatting and the overlay design is working perfectly. I'm attaching the screenshots for your reference. RTBC.
Thanks!
Comment #12
mandclu commentedUpdated issue summary.
Comment #13
mandclu commentedMore IS updates.
Comment #14
mandclu commentedComment #15
mandclu commentedUpdated to target a new 4.2.x branch.
Comment #17
mandclu commentedMerged in, and will include in a beta release for the 4.2.x branch.