I created a "Smart date range" field with the configuration in the screenshot.

My problem :

When I click on the "Add another item" button, nothing happens. Double-click the button to add another item.

After the following works correctly with a single click.

Comments

zenimagine created an issue. See original summary.

zenimagine’s picture

There are no errors in the logs or in the console.

mandclu’s picture

Status: Active » Postponed (maintainer needs more info)

Works fine for me on a clean install of Drupal. I'll need more detailed steps to reproduce before I can work on this.

zenimagine’s picture

StatusFileSize
new88.24 KB

There are no errors or warnings in the logs or in the console. Here is my server configuration.

zenimagine’s picture

Here is a video of the abnormal behavior :

https://webm.red/view/0Hme.webm

hhvardan’s picture

Status: Postponed (maintainer needs more info) » Active

I can confirm that the issue exists.
I've checked 3.7.0-beta version on both 9 and 10 Drupal versions.
Also, when the "Allowed number of values" is equal N which is greater than 1, the form displays N-1 items.
I think both issues related to each other.

hhvardan’s picture

This happens because of the following added into the \Drupal\smart_date\Plugin\Field\FieldWidget\SmartDateWidgetBase::formMultipleElements function.

if ($max > 0 && !$this->getSetting('show_extra')) {
      $max -= 1;
}

This change is related to the this issue #3166698: Option to not show an empty field by default

tostinni’s picture

Still happening on Drupal 10.1 and Smart Date 4.0.3

mandclu’s picture

Version: 3.6.x-dev » 4.1.x-dev

I was able to figure out that this happens when no default value is set, which is why I wasn't able to reproduce it before, using "Next hour" as the default. I will work on a fix.

mandclu’s picture

Status: Active » Needs review

Here's a patch that should get the button working as expected with and without a default value.

mandclu’s picture

StatusFileSize
new875 bytes

Helps if I actually attach the patch file lol

djsagar’s picture

Status: Needs review » Reviewed & tested by the community
StatusFileSize
new241.99 KB
new575.28 KB

After applied patch #11, issue is resolved shared attachment for reference.

Please review.

Regard!

  • mandclu committed 011d5ddc on 4.1.x
    Issue #3322456 by mandclu, hhvardan: The "Add another item" button does...
mandclu’s picture

Status: Reviewed & tested by the community » Fixed

Thanks all. I'm glad we were able to get to the bottom of this one.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.