anuzpandey / nepali-date-picker

Lightweight, Powerful JavaScript Nepali Date Picker with no dependencies.
https://date-picker.anuzpandey.com/
8 stars 2 forks source link

Bug Fix for Button Click Event in Nepali Date Picker Plugin #2

Closed DanyOli closed 6 months ago

DanyOli commented 6 months ago

I think, I encountered an issue with the button, classes click event not functioning properly in the plugin. Upon investigation, I found that the default behavior of the button click event was being prevented unconditionally, which was causing unintended side effects such as buttons not responding to clicks.

After debugging the code, I identified that the e.preventDefault() call was placed before checking whether the clicked element had a specific class (ap-cell-button). As a result, the default event behavior was being prevented for all button, classes clicks, regardless of whether they were within the intended scope.

To resolve this issue, I moved the e.preventDefault() call below the condition e.target.classList.contains("ap-cell-button") in the event listener function. This adjustment ensures that the default behavior of the button click event is prevented only when the clicked element meets the specific criteria, addressing the issue effectively.

This fix enhances the usability and functionality of the plugin by ensuring that button click events are handled correctly, contributing to a smoother user experience.

I have tested the fix and confirmed that it resolves the issue. Therefore, I recommend applying this modification to the plugin codebase to improve its reliability and performance.

Please review and consider integrating this bug fix into the plugin codebase to enhance its overall quality and user satisfaction.

If you need further clarification or assistance, feel free to reach out. Thank you for your attention to this matter.

anuzpandey commented 6 months ago

Thank you for the feedback. But can you give provide me the reproduction link so that I can clearly understand the issue you faced. As per my testing every buttons are working correctly and have no issue.

anuzpandey commented 6 months ago

I did find the issue with any other buttons events being stopped with e.preventDefault(). I removed the event cancellation mechanism on the new update as it was not necessary if I add the button type attribute as button. Please check once with the new update. I have closed the issue for now. Feel free to reach out if you encounter the same or any other issue.

Thank you again.