Skip to content

Commit cc878bd

Browse files
committed
Implement close after click and ESC event for address menu
1 parent d24e4d1 commit cc878bd

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

admin/app/components/solidus_admin/orders/show/address/component.html.erb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
</h2>
1111

1212
<% if @user&.addresses&.any? %>
13-
<details class="text-black text-sm" data-controller="details-click-outside">
13+
<details class="text-black text-sm" data-controller="details-click-outside" data-<%= stimulus_id %>-target="addresses">
1414
<summary
1515
class="text-left flex cursor-pointer select-none"
1616
data-action="keydown.esc-><%= stimulus_id %>#close"
@@ -24,6 +24,7 @@
2424
<%= tag.a(
2525
href: solidus_admin.send("order_#{@type}_address_path", @order, address_id: address.id),
2626
class: 'block text-black text-sm hover:bg-gray-50 p-2 mx-2 w-auto rounded-lg',
27+
'data-action': "#{stimulus_id}#close",
2728
) do %>
2829
<%= format_address(address) %>
2930
<% end %>
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import { Controller } from '@hotwired/stimulus'
2+
3+
export default class extends Controller {
4+
static targets = ["addresses"]
5+
6+
close() {
7+
this.addressesTarget.removeAttribute('open')
8+
}
9+
}

0 commit comments

Comments
 (0)