- <% if transaction.transfer? %>
- <%= link_to(
- entry.name,
- transaction.transfer.present? ? transfer_path(transaction.transfer) : entry_path(entry),
- data: {
- turbo_frame: "drawer",
- turbo_prefetch: false
- },
- class: "hover:underline"
- ) %>
- <% else %>
- <%= link_to(
- entry.name,
- in_split_group ? entry_path(entry, grouped: true) : entry_path(entry),
- data: {
- turbo_frame: "drawer",
- turbo_prefetch: false
- },
- class: "hover:underline"
- ) %>
- <% end %>
+ <%= link_to(
+ entry.name,
+ open_path,
+ data: {
+ turbo_frame: "drawer",
+ turbo_prefetch: false,
+ clickable_row_target: "link"
+ },
+ class: "hover:underline"
+ ) %>
diff --git a/test/controllers/accounts_controller_test.rb b/test/controllers/accounts_controller_test.rb
index 2bb01af1b..44fa65cc5 100644
--- a/test/controllers/accounts_controller_test.rb
+++ b/test/controllers/accounts_controller_test.rb
@@ -16,6 +16,18 @@ class AccountsControllerTest < ActionDispatch::IntegrationTest
assert_select "p.ml-auto.privacy-sensitive"
end
+ test "index delegates whole-row account clicks to the account link" do
+ get accounts_url
+
+ assert_response :success
+ doc = Nokogiri::HTML::Document.parse(response.body)
+ row = doc.at_css("turbo-frame##{dom_id(@account)} [data-controller='clickable-row']")
+ account_link = row.at_css("a[data-clickable-row-target='link']")
+
+ assert_equal "click->clickable-row#open", row["data-action"]
+ assert_equal account_path(@account), account_link["href"]
+ end
+
test "index localizes the Plaid add accounts action" do
ensure_tailwind_build
@user.update!(locale: "de")
@@ -128,6 +140,21 @@ class AccountsControllerTest < ActionDispatch::IntegrationTest
assert_equal 0, per_row_transfer, "N+1 per-row transfer queries detected (#{per_row_transfer})"
end
+ test "show delegates whole-row trade clicks to the drawer link" do
+ investment_account = accounts(:investment)
+ entry = entries(:trade)
+
+ get account_url(investment_account)
+
+ assert_response :success
+ doc = Nokogiri::HTML::Document.parse(response.body)
+ row = doc.at_css("turbo-frame##{dom_id(entry.entryable)} [data-controller='clickable-row']")
+ drawer_link = row.at_css("a[data-clickable-row-target='link']")
+
+ assert_equal "click->clickable-row#open", row["data-action"]
+ assert_equal entry_path(entry), drawer_link["href"]
+ end
+
test "show avoids N+1 split-parent queries across paginated entries" do
queries = capture_sql_queries { get account_url(@account) }
assert_response :success
diff --git a/test/controllers/transactions_controller_test.rb b/test/controllers/transactions_controller_test.rb
index 570ea1c65..4dcfe010c 100644
--- a/test/controllers/transactions_controller_test.rb
+++ b/test/controllers/transactions_controller_test.rb
@@ -488,6 +488,43 @@ class TransactionsControllerTest < ActionDispatch::IntegrationTest
assert_select ".split-group > div.opacity-50 p.privacy-sensitive", count: 1
end
+ # Row only opened on a precise click on the name text (whitespace between
+ # name/avatar/amount looked clickable via the row's hover styling but did
+ # nothing). A row-level click delegates to the name link now, so the whole
+ # row opens the drawer while interactive descendants (checkbox, category
+ # menu, account link) keep handling their own clicks.
+ test "transaction row delegates whole-row clicks to the drawer link" do
+ get transactions_url
+
+ assert_response :success
+ doc = Nokogiri::HTML::Document.parse(response.body)
+ frame_id = ActionView::RecordIdentifier.dom_id(@entry.entryable)
+ row = doc.at_css("turbo-frame##{frame_id} [data-controller='clickable-row']")
+ drawer_link = row.at_css("a[data-clickable-row-target='link']")
+
+ assert_equal "click->clickable-row#open", row["data-action"]
+ assert_equal entry_path(@entry), drawer_link["href"]
+ end
+
+ test "split parent row delegates whole-row clicks to the drawer link" do
+ entry = create_transaction(account: accounts(:depository), amount: 100, name: "Split parent")
+
+ entry.split!([
+ { name: "Part 1", amount: 60, category_id: nil },
+ { name: "Part 2", amount: 40, category_id: nil }
+ ])
+
+ get transactions_url
+
+ assert_response :success
+ doc = Nokogiri::HTML::Document.parse(response.body)
+ row = doc.at_css(".split-group [data-controller='clickable-row']")
+ drawer_link = row.at_css("a[data-clickable-row-target='link']")
+
+ assert_equal "click->clickable-row#open", row["data-action"]
+ assert_equal entry_path(entry), drawer_link["href"]
+ end
+
test "can paginate" do
family = families(:empty)
sign_in users(:empty)