Skip to content

fileuploader fixed - #119

Merged
veronika-tseleva-cleantalk merged 2 commits into
devfrom
fix_55346
Aug 20, 2026
Merged

fileuploader fixed#119
veronika-tseleva-cleantalk merged 2 commits into
devfrom
fix_55346

Conversation

@veronika-tseleva-cleantalk

Copy link
Copy Markdown
Contributor

No description provided.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR aims to harden the widget’s file uploader and automatic screenshot flow by adding defensive guards and correcting element-detection logic, with the compiled bundle updated accordingly.

Changes:

  • Adds guarded FileUploader initialization and safer screenshot invocation in the widget open flow.
  • Fixes FileUploader.initializeElements() to warn when the uploader wrapper is missing (correcting the prior inverted condition).
  • Updates the built dist/doboard-widget-bundle.js output to reflect the source changes.

Reviewed changes

Copilot reviewed 2 out of 5 changed files in this pull request and generated 1 comment.

File Description
js/src/widget.js Adds defensive initialization and optional-chained guards around FileUploader and makeScreenshot() usage.
js/src/fileuploader.js Corrects missing-element detection and adds additional safety checks around screenshot creation/DOM integration.
dist/doboard-widget-bundle.js Rebuild output reflecting the source changes (including the updated file uploader logic).

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread js/src/fileuploader.js
Copilot AI review requested due to automatic review settings August 20, 2026 11:33

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 2 out of 5 changed files in this pull request and generated no new comments.

Suppressed comments (4)

js/src/fileuploader.js:517

  • validateFile, clearError, and addFile are class methods, so the added typeof ... === 'function' checks add noise and can mask real defects. Also addFileError.message may be undefined; logging the full error preserves stack/context.
            if (typeof this.validateFile === 'function' && this.validateFile(file)) {

                if (this.uploaderWrapper && this.uploaderWrapper.style && this.uploaderWrapper.style.display !== 'block') {
                    this.uploaderWrapper.style.display = 'block';
                }

js/src/widget.js:949

  • This condition can be simplified: this is not optional here, and checking this?.fileUploader?.makeScreenshot before typeof ... === 'function' is redundant.
                if (!this?.nonRequesting && this?.fileUploader?.makeScreenshot && typeof this?.fileUploader?.makeScreenshot === 'function') {

js/src/widget.js:947

  • this is already used unguarded just above, so optional-chaining on this here and the if (this?.fileUploader) check are redundant. Also logging only error.message drops stack/context; log the error object instead.

This issue also appears on line 949 of the same file.

                this.fileUploader = new FileUploader(this?.escapeHtml);
                if (this?.fileUploader) {
                    try {
                        this.fileUploader.init();
                    } catch (error) {

js/src/fileuploader.js:427

  • The screenshot guard condition has redundant checks (this.files is always initialized as an array in the constructor), and the log message mentions "not fully initialized" even though no init state is checked. This makes the code harder to reason about.

This issue also appears on line 513 of the same file.

        if (!this.files || !Array.isArray(this.files) || this.files.length >= this.maxFiles) {
            console.log('SpotFix: File count limit reached or file uploader is not fully initialized.');
            return;
        }

@veronika-tseleva-cleantalk
veronika-tseleva-cleantalk merged commit 03e0cff into dev Aug 20, 2026
2 checks passed
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.

5 participants