From 72fb40b1c1beab2e315995bd1f8ac4007989b160 Mon Sep 17 00:00:00 2001 From: Matt Van Horn <455140+mvanhorn@users.noreply.github.com> Date: Fri, 27 Mar 2026 01:37:53 -0700 Subject: [PATCH 1/3] fix: remove required attribute when hiding social link row When a social link with validation errors is removed via the "Remove" button, the row is hidden with d-none but the input retains its required attribute. This prevents form submission because HTML5 validation rejects hidden required fields that cannot be focused. Strip the required attribute from the text input when marking a social link for destruction so the form can be resubmitted. Closes #6903 Co-Authored-By: Claude Opus 4.6 --- app/assets/javascripts/user.js | 1 + test/system/profile_links_change_test.rb | 26 ++++++++++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/app/assets/javascripts/user.js b/app/assets/javascripts/user.js index 8fcde7c1b2e..0852f052125 100644 --- a/app/assets/javascripts/user.js +++ b/app/assets/javascripts/user.js @@ -21,6 +21,7 @@ $(function () { if (destroyCheckbox) { destroyCheckbox.checked = true; row.addClass("d-none"); + row.find("input[type='text']").removeAttr("required"); } else { row.remove(); } diff --git a/test/system/profile_links_change_test.rb b/test/system/profile_links_change_test.rb index a1be4795da7..d38d341be08 100644 --- a/test/system/profile_links_change_test.rb +++ b/test/system/profile_links_change_test.rb @@ -168,4 +168,30 @@ class ProfileLinksChangeTest < ApplicationSystemTestCase assert_link "example.com/d" end end + + test "can remove invalid link after validation error and resubmit" do + user = create(:user) + + sign_in_as(user) + visit user_path(user) + + within_content_body do + click_on "Edit Profile Details" + click_on "Edit Links" + click_on "Add Social Link" + fill_in "Social Profile Link 1", :with => "https://example.com/valid" + click_on "Add Social Link" + click_on "Update Profile" + + assert_field "Social Profile Link 2" + + click_on "Remove Social Profile Link 2" + + assert_no_field "Social Profile Link 2" + + click_on "Update Profile" + + assert_link "example.com/valid" + end + end end From 8e8f42ce10959833f2bd87ac2e14a22e3e504ea8 Mon Sep 17 00:00:00 2001 From: Matt Van Horn Date: Sat, 28 Mar 2026 23:27:44 -0700 Subject: [PATCH 2/3] fix: also strip required attr in :checked.each on page load --- app/assets/javascripts/user.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/assets/javascripts/user.js b/app/assets/javascripts/user.js index 0852f052125..3413d6a6f6d 100644 --- a/app/assets/javascripts/user.js +++ b/app/assets/javascripts/user.js @@ -30,7 +30,9 @@ $(function () { }); $(".social_link_destroy input[type='checkbox']:checked").each(function () { - $(this).closest(".row").addClass("d-none"); + const row = $(this).closest(".row"); + row.addClass("d-none"); + row.find("input[type='text']").removeAttr("required"); }); renumberSocialLinks(); From d474aebfc1f67601e44c67f443b2ccfa3172b5cc Mon Sep 17 00:00:00 2001 From: Matt Van Horn Date: Mon, 30 Mar 2026 20:17:27 -0700 Subject: [PATCH 3/3] refactor: chain jQuery calls in checked.each loop Co-Authored-By: Claude Opus 4.6 (1M context) --- app/assets/javascripts/user.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/app/assets/javascripts/user.js b/app/assets/javascripts/user.js index 3413d6a6f6d..7607ad9bceb 100644 --- a/app/assets/javascripts/user.js +++ b/app/assets/javascripts/user.js @@ -30,9 +30,7 @@ $(function () { }); $(".social_link_destroy input[type='checkbox']:checked").each(function () { - const row = $(this).closest(".row"); - row.addClass("d-none"); - row.find("input[type='text']").removeAttr("required"); + $(this).closest(".row").addClass("d-none").find("input[type='text']").removeAttr("required"); }); renumberSocialLinks();