From 222af635ae869fdf4998e05c582a83db0fc92c6c Mon Sep 17 00:00:00 2001 From: Moritz Date: Tue, 16 Dec 2025 14:48:18 +0100 Subject: [PATCH] fix: make disabled links more robust in CoreComponents.button Remove navigation attributes (href, navigate, patch) when disabled=true to prevent 'Open in new tab' and 'Copy link' from working on disabled links. This makes the disabled state semantically stronger and independent of CSS themes. --- lib/mv_web/components/core_components.ex | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/mv_web/components/core_components.ex b/lib/mv_web/components/core_components.ex index f0a9fdb..a1020ef 100644 --- a/lib/mv_web/components/core_components.ex +++ b/lib/mv_web/components/core_components.ex @@ -115,9 +115,12 @@ defmodule MvWeb.CoreComponents do else: ["btn", assigns.class] # Prevent interaction when disabled + # Remove navigation attributes to prevent "Open in new tab", "Copy link" etc. link_attrs = if assigns[:disabled] do - Map.merge(rest, %{tabindex: "-1", "aria-disabled": "true"}) + rest + |> Map.drop([:href, :navigate, :patch]) + |> Map.merge(%{tabindex: "-1", "aria-disabled": "true"}) else rest end