Skip to content

Fix social link form resubmission after removing invalid link#6945

Open
mvanhorn wants to merge 3 commits intoopenstreetmap:masterfrom
mvanhorn:fix-social-link-remove-validation
Open

Fix social link form resubmission after removing invalid link#6945
mvanhorn wants to merge 3 commits intoopenstreetmap:masterfrom
mvanhorn:fix-social-link-remove-validation

Conversation

@mvanhorn
Copy link
Copy Markdown
Contributor

Summary

Fixes #6903.

When a social link row is removed after a validation error, the row is hidden (d-none) and the _destroy checkbox is checked, but the text input keeps its required attribute. HTML5 validation then blocks form submission because it cannot focus the hidden required field.

This adds a single line to strip the required attribute from the text input when marking a social link for destruction.

Reproduction

  1. Go to profile links editor with no existing links
  2. Add a valid URL, then add a second empty social link
  3. Submit - server returns validation error on the empty link
  4. Remove the errored link
  5. Try to submit again - before this fix, nothing happens and the console logs "invalid form control is not focusable"

Test plan

  • Added system test covering the exact reproduction scenario
  • Existing social link tests continue to pass (add, remove, keyboard navigation, multi-link management)

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 openstreetmap#6903

Co-Authored-By: Claude Opus 4.6 <[email protected]>
Comment thread app/assets/javascripts/user.js
@hlfan
Copy link
Copy Markdown
Collaborator

hlfan commented Mar 29, 2026

Please see #6937 (comment) and the guideline for pull requests.

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
@mvanhorn
Copy link
Copy Markdown
Contributor Author

Chained the jQuery calls in the checked.each loop in d474aeb - removed the unnecessary const. Thanks for the pointer to #6937.

@tomhughes tomhughes added the ai-assisted Suggestions making extensive use of outsourced intelligence label Mar 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ai-assisted Suggestions making extensive use of outsourced intelligence

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Error handling bug with social links

3 participants