Files
sure/app/views/transactions/_split_parent_row.html.erb
T
ab175cc43c fix(ui): make whole list row clickable, not just the name text (#3367)
* fix(ui): make whole list row clickable, not just the name text

Fixes #3366. Transaction, split-parent, trade, and account list rows carry
hover styling that implies the whole row is clickable, but only the name
text actually opened the detail drawer — clicking the avatar, amount, or
whitespace between them did nothing. Add a clickable-row Stimulus
controller that delegates a click anywhere on the row to its primary link,
while leaving real interactive descendants (checkbox, category menu,
account link, quick-edit badge, kebab menu) to handle their own clicks.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

* fix(ui): exclude popover/menu panels from row click delegation, preserve modifier clicks

Codex review on #3367 flagged two issues in clickable_row_controller:
- Category/account popovers render as position:fixed but stay DOM
  descendants of the row, so clicking their background (padding,
  headings, plain text) fell through to the row's link.
- linkTarget.click() discarded Ctrl/Cmd/Shift modifiers, so
  modified clicks opened in the current frame instead of a new tab.

* fix(ui): exclude quick-edit dropdown, use window.open for modified clicks

CodeRabbit review on #3367 found two more issues:
- The investment activity quick-edit dropdown is a hand-rolled
  absolute-positioned panel (not DS::Popover/DS::Menu), so it wasn't
  covered by the earlier popover/menu exclusion and background clicks
  inside it fell through to the row link.
- Redispatching a synthetic MouseEvent with modifier flags doesn't
  actually open a new tab: browsers only honor Ctrl/Cmd/Shift on
  trusted, native click events, so the previous "fix" was cosmetic.
  Explicitly call window.open() for modified clicks instead.

* fix(ui): make Dividend/Interest quick-edit badge not swallow row clicks

jjmata found that the activity-label badge renders as a real <button>
even when Dividend/Interest trades have no dropdown/click handler
(income_trade), so clickable-row's "a, button, ..." exclusion still
treats it as an interactive descendant and swallows the click instead
of opening the row — same dead-spot symptom as #3366, relocated to
this one badge. Render it as a <span> in that case so the row click
delegates normally.

* fix(ui): show pointer cursor on delegated Dividend/Interest badge

CodeRabbit caught that the badge kept cursor-default after becoming a
non-interactive <span> that delegates its click to the row link — the
cursor no longer matched the actual (now clickable) behavior.

---------

Co-authored-by: GFR <248542187+gfr-free@users.noreply.github.com>
Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>
2026-09-05 08:27:16 +02:00

74 lines
2.7 KiB
ERB

<%# locals: (entry:) %>
<% transaction = entry.entryable %>
<div class="group flex lg:grid lg:grid-cols-12 items-center text-sm font-medium p-3 lg:p-4 opacity-50 text-secondary"
data-controller="clickable-row"
data-action="click->clickable-row#open">
<div class="pr-4 lg:pr-10 flex items-center gap-3 lg:gap-4 col-span-8 min-w-0">
<%# Empty space where checkbox would be, for alignment %>
<div class="hidden lg:block w-4 shrink-0"></div>
<div class="max-w-full">
<div class="flex items-center gap-3 lg:gap-4">
<div class="hidden lg:flex">
<% if transaction.merchant&.logo_url.present? %>
<%= image_tag Setting.transform_brand_fetch_url(transaction.merchant.logo_url),
class: "w-9 h-9 rounded-full border border-secondary",
loading: "lazy" %>
<% else %>
<div class="hidden lg:flex">
<%= render DS::FilledIcon.new(
variant: :text,
text: entry.name,
size: "lg",
rounded: true
) %>
</div>
<% end %>
</div>
<div class="truncate">
<div class="space-y-0.5">
<div class="flex items-center gap-1 min-w-0">
<div class="truncate flex-shrink">
<%= link_to entry.name,
entry_path(entry),
data: { turbo_frame: "drawer", turbo_prefetch: false, clickable_row_target: "link" },
class: "hover:underline" %>
</div>
<div class="flex items-center gap-1 flex-shrink-0">
<%= render DS::Pill.new(
label: t("transactions.split_parent_row.split_label"),
tone: :neutral,
marker: false,
icon: "split"
) %>
</div>
</div>
<div class="text-secondary text-xs font-normal">
<% if transaction.merchant&.present? %>
<span class="hidden lg:inline truncate"><%= transaction.merchant.name %></span>
<% end %>
<span class="text-secondary hidden lg:inline">
<%= link_to entry.account.name,
account_path(entry.account, tab: "transactions"),
data: { turbo_frame: "_top" },
class: "hover:underline" %>
</span>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="hidden md:flex items-center gap-1 col-span-2">
</div>
<div class="shrink-0 col-span-4 lg:col-span-2 ml-auto flex items-center justify-end gap-2">
<%= content_tag :p, format_money(-entry.amount_money), class: "privacy-sensitive" %>
</div>
</div>