diff --git a/docs/app/javascript/controllers/ruby_ui/dropdown_menu_controller.js b/docs/app/javascript/controllers/ruby_ui/dropdown_menu_controller.js index d624eaf5..6479c844 100644 --- a/docs/app/javascript/controllers/ruby_ui/dropdown_menu_controller.js +++ b/docs/app/javascript/controllers/ruby_ui/dropdown_menu_controller.js @@ -43,7 +43,7 @@ export default class extends Controller { #computeTooltip() { computePosition(this.triggerTarget, this.contentTarget, { - placement: this.optionsValue.placement || "top", + placement: this.optionsValue.placement || "bottom", middleware: [flip(), shift(), offset(8)], strategy: this.optionsValue.strategy || "absolute", }).then(({ x, y }) => { @@ -73,12 +73,16 @@ export default class extends Controller { this.#deselectAll(); this.#addEventListeners(); this.#computeTooltip(); + // Lift the open menu above sibling dropdowns/elements. The container has no + // static z-index, so closed siblings stack in normal flow and never cover it. + this.element.style.zIndex = "50"; this.contentTarget.classList.remove("hidden"); } close() { this.openValue = false; this.#removeEventListeners(); + this.element.style.zIndex = ""; this.contentTarget.classList.add("hidden"); } diff --git a/docs/app/views/docs/dropdown_menu.rb b/docs/app/views/docs/dropdown_menu.rb index effa942b..4588a301 100644 --- a/docs/app/views/docs/dropdown_menu.rb +++ b/docs/app/views/docs/dropdown_menu.rb @@ -11,7 +11,7 @@ def view_template render Docs::VisualCodeExample.new(title: "Example", context: self) do <<~RUBY DropdownMenu do - DropdownMenuTrigger(class: 'w-full') do + DropdownMenuTrigger do Button(variant: :outline) { "Open" } end DropdownMenuContent do @@ -29,7 +29,7 @@ def view_template render Docs::VisualCodeExample.new(title: "Non-navigational item", description: "Use as: :div when the item hosts its own interactive element (e.g. a dialog or form trigger). This avoids nesting a