From 077aa58dbd2fed37c3cfcbe62ceab0d753ee1f3a Mon Sep 17 00:00:00 2001 From: Matt Van Horn Date: Tue, 4 Aug 2026 23:21:56 -0700 Subject: [PATCH] Fix social link form resubmission after removing invalid link (#6945) 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 --- app/assets/javascripts/user.js | 3 ++- test/system/profile_links_change_test.rb | 26 ++++++++++++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/app/assets/javascripts/user.js b/app/assets/javascripts/user.js index 6b84cfeca..eb87ee91d 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(); } @@ -29,7 +30,7 @@ $(function () { }); $(".social_link_destroy input[type='checkbox']:checked").each(function () { - $(this).closest(".row").addClass("d-none"); + $(this).closest(".row").addClass("d-none").find("input[type='text']").removeAttr("required"); }); renumberSocialLinks(); diff --git a/test/system/profile_links_change_test.rb b/test/system/profile_links_change_test.rb index a1be4795d..d38d341be 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 -- 2.47.3