Skip to content

How to use field wrappers for inline edit #3495

Open
@pjmuller

Description

@pjmuller

Feature

I added inline edit feature but in a dirty way, I believe that I can do it better via https://docs.avohq.io/3.0/field-wrappers.html but can't connect the dots yet.

See https://www.loom.com/share/179e5d4f3a914879b09f6dd29be33698

Current workarounds

I'm adding the html in the name part of a field via a block, and then aligning it to the right

field :foobar, as: :text, name: -> {
  path, data = Avo::Actions::SingleEdit.link_arguments(resource: resource)
  ActionController::Base.helpers.content_tag(:span, "my field") +
                   ActionController::Base.helpers.link_to('✎', path,
                                                          data: data,
                                                          class: 'ml-auto',
                                                          style: 'position: absolute; right: 1.5rem')
}

and styling

[data-slot="label"] a {
  position: absolute;
  right: 1.5rem;  /* 24px, matching the parent's padding-x of 6 */
  top: 50%;
  transform: translateY(-50%);
  z-index: 1;
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    Triage

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions