activeadmin / arbre

An Object Oriented DOM Tree in Ruby

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Nested Form Fields Rendered Twice in 1.2.0 Release

macfanatic opened this issue · comments

After upgrading to the latest activeadmin and arbre, we realized that our nested form fields are being duplicated in our templates.

  • activeadmin 1.3.1
  • arbre 1.2.0
  • rails 5.2.3
  • ruby 2.3.6

Example form for ActiveAdmin resource:

ActiveAdmin.register Drawer do
  form do |f|
    columns do
      column do
        panel 'Payment Methods' do
          table do
            thead do
              th 'Payment Method'
              th 'Amount Processed'
              th 'Expected on Hand'
            end

            tbody do
              f.semantic_fields_for :payments do |payments|
                tr(class: cycle('odd', '')) do
                  td(class: 'hidden') { payments.input :id, as: :hidden }
                  td { payments.object.payment_method.name }
                  td { payments.object.amount_processed.format }
                  td { payments.object.amount_expected_on_hand.format }
                end
              end
            end
          end
        end
      end
    end
  end
end

We end up with the semantic_fields_for rendering double the amount of rows, a whole group and then the entire collection again a second time.

Leaving activeadmin and rails locked to the versions mentioned above, but downgrading to arbre version 1.1.1 (the previous release) fixes the issue.

Thansk for the report, I'll have a look 👍

How does it look with arbre 1.1.1?

Apologies, typo - we are locked and using arbre 1.1.1 as the fix, not 1.1.0 as written.

I updated the issue info above.

What about activeadmin 2.0.0.rc1? Does it work there? Also, can you provide a sample application reproducing the regression?

The issue exists in all the following configurations:

  • arbre 1.2.0.rc1 and activeadmin 1.3.1
  • arbre 1.2.0 and activeadmin 1.3.1
  • arbre 1.2.0 and activeadmin 2.0.0.rc1

The issue does not exist with:

  • arbre 1.1.1 and activeadmin 1.3.1
  • arbre 1.1.1 and activeadmin 2.0.0.rc

It very much appears to have been introduced and present in both the arbre RC1 and final versions.

I'll see if I can get a demo repo setup and shared to reproduce.

Here is a link to a reproduction repo, the README includes setup and what to do for viewing the issue.

https://github.com/madebylotus/arbre-regression-1.2.0-example

Nice, thanks so much @macfanatic!

Run a bisection over you app and the culprit seems #64.

Here's another example where double rendering happens: one form accidentally included f.actions inside of f.inputs, leading to the submit and cancel buttons to be double-rendered. It was easy enough to fix by moving it out of the inputs block.

  form do |f|
    f.inputs do
      # ...

      f.actions
    end
  end

Screen Shot 2019-04-11 at 10 14 32 AM

I worked a bit on this today in this branch.

It sounds like regardless of how we end up fixing #46, we should probably revert #64.