diff --git a/app/assets/javascripts/user.js b/app/assets/javascripts/user.js index 8fcde7c1b2e..7607ad9bceb 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 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