If you follow the standard steps to have an entity browser with two tabs which are
1. an upload widget and
2. a view to select entities

If you have a reset option on the exposed filters when you click on it to reset the view it instead loads the upload tab. I'd expect the reset button to simply reset the view.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

vaccinemedia created an issue. See original summary.

samuel.mortenson’s picture

Category: Support request » Bug report
John Pitcairn’s picture

Reproducible here. Rats.

Weilinggu’s picture

Noticed that this only happens in Tabs widget selector. Added a check so when user click reset, it wouldn't trigger tab switching.
Logic: If form_state has "op" input, it means it's coming from view, there is no reason to trigger submit in Tabs.php

Weilinggu’s picture

Status: Active » Needs review
marie.pinet’s picture

Status: Needs review » Needs work

Hi,

I have a same problem in my project.

I have "2 types" of entity browser :

  • type 1: with only a entity view,
  • type 2: with an entity view in first and one or more entity form.

Without this patch, when I click on the reset button :

  • type 1 => the modal is closed,
  • type 2 => the active tab changed.

With this patch, when I click on the reset button :

  • type 1 => no change, the modal is closed,
  • type 2 => the active tab no changed.

When I make a breakpoint in the submit function patched, I can see that the trigger element is bad.
For examples :

  • type 1: the trigger is the entity browser submit button
  • type 2: the trigger is the next tab

But I don't have find where is the problem.

Thanks for your help.

Marie

hawkeye.twolf’s picture

Status: Needs work » Needs review
FileSize
1.31 KB

New patch attached to fix issues caused by the previous patch when the Views widget was not first in the list of tabs.

maximpodorov’s picture

Reset button can have translated or even modified label.

maximpodorov’s picture

This patch adds checking against the translated "Reset" string.

Fernly’s picture

Patches not working against the stable 8.x-2.4 release.

tekNorah’s picture

Status: Needs review » Reviewed & tested by the community

Successfully applied patch against 8.x-2.5 & 8.x-2.6 release.

Can we get this in the next release, please?

Nicolas Bouteille’s picture

Works for us too on 8.x-2.6 with modal + single widget. Thanks for the patch!
+1 RTBC

Berdir’s picture

The reset button string is configurable, getTriggeringElement() might allow to identify that more easily?

Berdir’s picture

Status: Reviewed & tested by the community » Needs work
plopesc’s picture

Hello,

I've been digging into this one and it seems that $form_state->getTriggeringElement() is not returning the Reset button, but the tab selector button added in WidgetSelectorBase::getForm().

Apparently, when clicking on the "Reset" button, the form being submitted is the parent one and to the views exposed one.

I have the feeling that will be necessary to add some JS in entity_browser.view.js to capture the Reset button event and proceed accordingly.

Another option would be to load the view in EntityBrowserForm::submitForm() and compare the button value with the value stored in the view. However, that would open the door to inconsistencies with other modules like BEF or custom exposed form plugins.

What do you think?