Problem/Motivation

The realItemsCount should be "Number of paragraphs item on form."

As there are some deleted ones and some without access, this does not necessarily mean the total count.

Proposed resolution

Check its use and fix the counter.

Currently sometimes it counts 1 after removing an item, so buttons are still visible that should only be visible when visible count is >0.

Remaining tasks

User interface changes

Consistent visibility of action items if paragraphs count =0 (no actions) or >0 (actions visible)

API changes

Hopefully none. If tests fail, we might need a different counter.

Comments

miro_dietiker created an issue. See original summary.

miro_dietiker’s picture

Priority: Normal » Major

Checked our nice code. :-)

So each Paragraph that is removed still builds its form element and then is set to #access FALSE at the very end.

      if ($item_mode == 'remove') {
        $element['#access'] = FALSE;
      }

And then even later the realItemsCount is corrected:

          if (isset($element['#access']) && !$element['#access']) {
            $this->realItemCount--;
          }

So yeah, at the end realItemCount is fine. But at that point it was used in many wrong contexts.

We need to initialize it earlier and also double check the ajax submit cases to avoid being double off or updated too late.