Merge branch 'main' into sidebar
Some checks reported errors
continuous-integration/drone/push Build encountered an error

This commit is contained in:
carla 2025-12-08 12:29:33 +01:00
commit bb6ea0085b
5 changed files with 44 additions and 45 deletions

View file

@ -474,6 +474,7 @@ defmodule MvWeb.CoreComponents do
slot :col, required: true do
attr :label, :string
attr :col_click, :any, doc: "optional column-specific click handler that overrides row_click"
end
slot :action, doc: "the slot for showing user actions in the last table column"
@ -509,8 +510,11 @@ defmodule MvWeb.CoreComponents do
<tr :for={row <- @rows} id={@row_id && @row_id.(row)}>
<td
:for={col <- @col}
phx-click={@row_click && @row_click.(row)}
class={["max-w-xs truncate", @row_click && "hover:cursor-pointer"]}
phx-click={
(col[:col_click] && col[:col_click].(@row_item.(row))) ||
(@row_click && @row_click.(row))
}
class={["max-w-xs truncate", (col[:col_click] || @row_click) && "hover:cursor-pointer"]}
>
{render_slot(col, @row_item.(row))}
</td>

View file

@ -1082,6 +1082,16 @@ defmodule MvWeb.MemberLive.Index do
|> Enum.map(&format_member_email/1)
end
@doc """
Returns a JS command to toggle member selection when clicking the checkbox column.
Used as `col_click` handler to ensure clicking anywhere in the checkbox column
toggles the checkbox instead of navigating to the member details.
"""
def checkbox_column_click(member) do
JS.push("select_member", value: %{id: member.id})
end
# Formats a member's email in the format "First Last <email>"
# Used for copy_emails feature and mailto links to create email-client-friendly format.
def format_member_email(member) do

View file

@ -65,6 +65,7 @@
<!-- <:col :let={member} label="Id">{member.id}</:col> -->
<:col
:let={member}
col_click={&MvWeb.MemberLive.Index.checkbox_column_click/1}
label={
~H"""
<.input
@ -81,11 +82,7 @@
<.input
type="checkbox"
name={member.id}
phx-click="select_member"
phx-value-id={member.id}
checked={MapSet.member?(@selected_members, member.id)}
phx-capture-click
phx-stop-propagation
aria-label={gettext("Select member")}
role="checkbox"
/>