Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Fix]:Enhanced efficiency by fixing the redundant adding of <p> tag to DOM #18

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Aashiq-Edavalapati
Copy link

@Aashiq-Edavalapati Aashiq-Edavalapati commented Jan 4, 2025

Fixes #8

This PR fixes an issue where multiple feedback messages were being appended to the feedbackContainer when the form was submitted multiple times. The solution now uses a single feedback element that updates dynamically, ensuring no duplicate messages are added.

Changes made:

  • I replaced the logic that was adding and removing separate <p> tags for success and error messages with a single reusable <p> tag.
  • Now, instead of adding new tags, we update the content and apply the relevant classes (success-msg or error-msg) based on whether the form is valid or not.
  • This change ensures that we only ever have one feedback message in the container, reducing unnecessary DOM manipulation and improving overall efficiency.

Why This is Better:

  • Performance Improvement: By reusing the same element and only updating it, we avoid clearing and recreating DOM elements repeatedly.
  • Simpler Code: The logic is more straightforward now that we're managing just one feedback element.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Error Message Appears Multiple Times Upon Form Submission
1 participant