1

Is there a way to add separators to a dropdown menu in activeadmin?

For example, if I wanted a separator between the first and second items, how can I do that?

  menu.add label: 'Tasks', priority: 10  do |tasks|
    tasks.add label:    'Add News Item',
             url:      proc { new_feed_path },
             if:       proc { authorized? :create, Feed },
             priority: 14
    tasks.add label:    'Add Calendar Event',
             url:      proc { new_event_path },
             if:       proc { authorized? :create, Event },
             priority: 15
  end

I checked the documentation but don't seem to see anything for that.

Chris Mendla
  • 987
  • 2
  • 10
  • 25

2 Answers2

0

As of writing this comment, ActiveAdmin is at version 1.2.1 and based on its code, it isn't possible to add separators/dividers in a dropdown menu. :(

I just checked on the Github repo and they have no opened issue nor pull request matching the "separator" or "divider" keywords.

Maybe the first step would be to open an issue describing what and how to implement it.

ZedTuX
  • 2,859
  • 3
  • 28
  • 58
0

Nothing is preventing us from adding a divider manually:

menu.add label: 'Tasks', priority: 10  do |tasks|
  tasks.add label:    'Add News Item',
            url:      proc { new_feed_path },
            if:       proc { authorized? :create, Feed },
            priority: 14
  tasks.add label:    "<hr>".html_safe,
            url:      "javascript:void(0)",
            priority: 15
  tasks.add label:    'Add Calendar Event',
            url:      proc { new_event_path },
            if:       proc { authorized? :create, Event },
            priority: 16
end

a url attribute is required so using javascript:void(0) is an option here as # will not render the label. This question discusses javascript:void(0)

screenshot of divider

SMAG
  • 652
  • 6
  • 12