Skip to content

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

@ha4gu

Description

@ha4gu

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:

  • The width of instance tabs broadly extends, as wide as other input field.
  • The nested field won't be closed; it would show up just after toggled up.

These behaviors occur in these cases:

  • Create (new) view

new-failed

  • Update (edit) view, if you push add button without opening the field beforehand

edit-failed

Not occur (works properly) in this case:

  • Update (edit) view, if you push add button after opening the field at first

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,

  • The width of instance tabs is fit to the length of strings inside, not fully expanded.
  • The nested field would be opened and then closed when toggle button is switched.

Additional context

  • rails version: 6.1.6
  • rails_admin version: 3.0.0, and also current master (652418c)
  • rails_admin npm package version: 3.0.0, and also current master (652418c)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions