Hide "Duration Custom" if only one option present

Created on 4 August 2023, about 1 year ago

Problem/Motivation

When trying to simplify the UI I thought it might be useful to only assign one Custom field, hoping the selector would be hidden. I was surprised when it then shows "Duration Custom" as a label instead of just hiding that label entirely.

Steps to reproduce

Configure a date field with only "custom" as a value on the duration field.

Proposed resolution

Don't show the Duration field if only "custom" is provided.
Make the Duration field optional, where it behaves as if "custom" was the only value.

Remaining tasks

Provide a patch.

User interface changes

Don't show the

API changes

n/a

Data model changes

n/a

✨ Feature request
Status

Active

Version

4.0

Component

User interface

Created by

πŸ‡ΊπŸ‡ΈUnited States DamienMcKenna NH, USA

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @DamienMcKenna
  • πŸ‡¨πŸ‡¦Canada mandclu

    Hi Damien, thanks for raising this interesting use case.

    I'm a little surprised because adding this concept of duration to simplify the entry of dates was actually the original idea that sparked the creation of Smart Date. I would add that the default behaviour is designed to leverage patterns users are accustomed to in popular calendar tools like Office 365, Google Calendar, and so on. Finally, I would caution that visual simplicity does not always equate to simplicity of use, and to me this is an example of that.

    All of that being said, what you have suggested shouldn't be hard to implement. I believe that the widget already hides the duration dropdown if the only allowed option is zero, so including "custom" in that logic should only require a small adjustment to the Javascript. Furthermore, if a site builder has set "custom" as the only allowed value, the dropdown will no longer be serving any useful purpose, so it does make sense to hide it.

    The only possible argument for leaving it in would be if we could dynamically update the label, so it could reflect the calculated duration based on the user input. I believe I explored this a while back and had a proof-of-concept working, but IIRC the complexity of making that work across languages was why I abandoned it.

    I will also add that for a while I've had an idea to make the duration element a little more dynamic. Rather than being a select that is always visible, the list of values could appear directly under the end time while the user is making changes. This would also align with popular calendar software, and make it more obvious (I think) have the elements relate to each other, in addition to visually cleaning up the widget.

  • Assigned to DamienMcKenna
  • πŸ‡ΊπŸ‡ΈUnited States DamienMcKenna NH, USA

    The reason I tried out this module in the first place was because core's date field lacks a lot of functionality that the D7 module provided, most notably configurable granularity. For our use case we don't need the extras, so I've been trying to pair down the options presented in the UI. I'll follow up next week, I might have time to work on this myself.

  • πŸ‡¨πŸ‡¦Canada mandclu

    Actually I just tested this and it seems to work the way you want using both the 4.0.x and 4.1.x branch. Is it possible you're currently using a version older than 4.0.0?

  • πŸ‡ΊπŸ‡ΈUnited States DamienMcKenna NH, USA

    It's v4.0.3.

Production build 0.71.5 2024