railsadminteam / rails_admin

RailsAdmin is a Rails engine that provides an easy-to-use interface for managing your data
MIT License
7.88k stars 2.25k forks source link

UI of nested field get weird after pushed "Add a new ..." button #3528

Closed ha4gu closed 2 years ago

ha4gu commented 2 years ago

Describe the bug

The UI of nested field for has_many association won't work properly on Rails Admin 3.0.0. After pushed "Add a new ..." button, you would find two strange points:

These behaviors occur in these cases:

new-failed

edit-failed

Not occur (works properly) in this case:

edit-ok

Reproduction steps

It's easy to reproduce this behavior; Simply create two models connected with has_many/belongs_to association. Here is my examples.

app/models/author.rb

class Author < ApplicationRecord
  has_many :books, dependent: :destroy
  accepts_nested_attributes_for :books
end

app/models/book.rb

class Book < ApplicationRecord
  belongs_to :author
end

config/initializers/rails_admin.rb

RailsAdmin.config do |config|
  config.asset_source = :webpacker

  config.actions do
    ((snip))
  end

  config.included_models = ['Author', 'Book']

  config.model 'Book' do
    include_fields :title
  end
end

Expected behavior

In the UI of nested field,

Additional context

mshibuya commented 2 years ago

Thanks for reporting, fixed by d1f115425c4a8d119fdeb37802fe472ae278918d.

ha4gu commented 2 years ago

I appreciate it! Now I confirmed the current master branch nicely resolved this issue. Thank you so much.