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 infinite file upload popup #309

Merged
merged 2 commits into from
Jun 26, 2024
Merged

Conversation

Soare-Robert-Daniel
Copy link
Contributor

@Soare-Robert-Daniel Soare-Robert-Daniel commented Jun 19, 2024

Summary

  • Added a guard that checks if the instance of Uploader is already initialized. 2f883cc
  • Refactor some variable names to express their scope better and eliminate the var keyword.

Context

If the File Input Field is not visible at first, it will go into an infinite initialization loop because of the recursion created by the PostInit event.

Users who are using conditional fields are affected by this problem.

PostInit: function() {
// file_list_preview_containers[file_data_name].html('');
if ( ! file_list_preview_containers[file_data_name].is(':visible') ) {
jQuery(document).on('ppom_field_shown', function() {
jQuery.each(ppom_input_vars.ppom_inputs, function(index, file_input) {
if (file_input && (file_input.type === 'file' || file_input.type === 'cropper')) {
if (
file_input.data_name &&
file_input.files_allowed &&
file_input.file_size &&
file_input.files_allowed
) {
ppom_setup_file_upload_input(file_input);
}
}
});
} );
}

Notes

I did a little experiment and dumbed the file-upload.js into ChatGPT to see if it could find the problem, and it worked.

Will affect visual aspect of the product

NO

Screenshots

Test instructions

  • Use this CSV file to upload the PPOM data: ppom-meta-1715239754.csv
  • View the product and test if you can add a file in the input field.

Check before Pull Request is ready:

Closes https://github.com/Codeinwp/ppom-pro/issues/329

@Soare-Robert-Daniel Soare-Robert-Daniel marked this pull request as ready for review June 19, 2024 09:17
@pirate-bot
Copy link
Contributor

Plugin build for f512dcc is ready 🛎️!

@pirate-bot pirate-bot added the pr-checklist-incomplete The Pull Request checklist is incomplete. (automatic label) label Jun 19, 2024
@Soare-Robert-Daniel Soare-Robert-Daniel added the pr-checklist-skip Allow this Pull Request to skip checklist. label Jun 19, 2024
@Soare-Robert-Daniel Soare-Robert-Daniel self-assigned this Jun 19, 2024
@pirate-bot pirate-bot added pr-checklist-complete The Pull Request checklist is complete. (automatic label) and removed pr-checklist-incomplete The Pull Request checklist is incomplete. (automatic label) labels Jun 19, 2024
Copy link
Contributor

@preda-bogdan preda-bogdan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe we an find a way to also test this.

@Soare-Robert-Daniel Soare-Robert-Daniel merged commit 8419660 into development Jun 26, 2024
14 of 17 checks passed
@Soare-Robert-Daniel Soare-Robert-Daniel mentioned this pull request Jun 26, 2024
@pirate-bot
Copy link
Contributor

🎉 This PR is included in version 32.0.23 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

@pirate-bot pirate-bot added the released Indicate that an issue has been resolved and released in a particular version of the product. label Jul 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr-checklist-complete The Pull Request checklist is complete. (automatic label) pr-checklist-skip Allow this Pull Request to skip checklist. released Indicate that an issue has been resolved and released in a particular version of the product.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants