danmunn / redmine_dmsf

Fork of svn repository for redmine_dmsf
GNU General Public License v2.0
417 stars 195 forks source link

Uncaught SyntaxError: Redeclaration of let modal in Approval Workflow Log #1510

Closed Daugava closed 7 months ago

Daugava commented 7 months ago

Description We've encountered a JavaScript syntax error "Uncaught SyntaxError: redeclaration of let modal" when users attempt to view the "Approval Workflow log" for a DMS document. This error appears in the console under specific conditions, affecting user interaction with the DMS document's workflow logs.

Steps to Reproduce Navigate to "DMS Documents". Click on "Workflow" for a specific document. Close the "Approval Workflow log" window. Click on "Workflow" for the same or another specific document. Observe the error in the console. Expected Behavior Users should be able to open, close, and reopen the "Approval Workflow log" for DMS documents without encountering JavaScript errors in the console.

Actual Behavior When following the steps above, a JavaScript error "Uncaught SyntaxError: redeclaration of let modal" is thrown in the console, potentially impacting the functionality and user experience.

Possible Solution A potential solution to this issue is to change the declaration of the modal variable from let to var in all instances where it appears, to avoid block scope redeclaration issues. This change is suggested for the following files:

./app/views/dmsf_folder_permissions/new.js.erb ./app/views/dmsf_workflows/action.js.erb ./app/views/dmsf_workflows/log.js.erb ./app/views/dmsf_workflows/assign.js.erb ./app/views/dmsf/add_email.js.erb

Changing the variable declaration from let to var will make modal scoped to the function rather than the block, preventing redeclaration errors across different script tags.

Affected Versions:

Redmine version: 5.1.1.stable Ruby version: 3.0.6-p216 (2023-03-30) [x86_64-linux] Rails version: 6.1.7.6 Environment: Based on Bitnami stack

picman commented 7 months ago

A good catch! Fixed according to your suggestion.