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(file-item): improve progressbar ui when uploading from external URLs #784

Merged
merged 2 commits into from
Feb 3, 2025

Conversation

nd0ut
Copy link
Member

@nd0ut nd0ut commented Jan 23, 2025

https://v.usetapes.com/JYy0RurdiR

Summary by CodeRabbit

  • New Features

    • Enhanced file upload user interface with contextual hints during the upload process.
    • Added a new "waiting for" status message across multiple language localization files.
  • Bug Fixes

    • Corrected a typo in the English localization for the validation error message.
  • Localization

    • Added "waiting for" translations in over 40 languages, improving internationalization support.
  • UI Improvements

    • Updated progress bar visibility and animation for better user feedback.
    • Added hint display for file upload states to enhance user experience.

Copy link
Contributor

coderabbitai bot commented Jan 23, 2025

Walkthrough

The pull request introduces enhancements to the file uploader component across multiple files. Key changes include adding a new hint property to the FileItem class for contextual feedback during uploads, improving the ProgressBar functionality by refining progress line visibility and handling, and expanding localization support by adding a new 'waiting-for' key across numerous language files. These modifications collectively enhance user experience by providing more detailed feedback during file upload processes.

Changes

File Change Summary
blocks/FileItem/FileItem.js Added hint property, new _updateHint method, updated _handleState to manage hint updates
blocks/ProgressBar/ProgressBar.js Introduced separate fakeProgressLine and realProgressLine references, updated progress value handling
blocks/ProgressBar/progress-bar.css Added new CSS variables and classes for progress animation and visibility
locales/file-uploader/*.js Added 'waiting-for' localization key across multiple language files
locales/file-uploader/en.js Corrected typo in 'has-validation-errors' message, added 'waiting-for' key

Sequence Diagram

sequenceDiagram
    participant User
    participant FileItem
    participant ProgressBar
    participant Localization

    User->>FileItem: Upload File
    FileItem->>FileItem: Initialize Hint
    FileItem->>ProgressBar: Update Progress
    ProgressBar->>ProgressBar: Manage Progress Visibility
    FileItem->>Localization: Get Localized Message
    Localization-->>FileItem: Return Waiting Message
    FileItem->>User: Display Hint
Loading

Poem

🐰 Uploading files, a rabbit's delight,
Hints and progress, now shining bright!
Locales dancing, from A to Z,
Smooth file transfer, oh what glee!
CodeRabbit's magic, smooth and light 🚀

✨ Finishing Touches
  • 📝 Generate Docstrings (Beta)

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@nd0ut nd0ut requested a review from egordidenko January 23, 2025 12:56
@nd0ut nd0ut changed the title fix(file-item): fix progressbar ui when uploading from external URLs fix(file-item): improve progressbar ui when uploading from external URLs Jan 23, 2025
@nd0ut nd0ut force-pushed the fix/from-url-progressbar branch from f9a0b1d to 2a4e6d1 Compare January 23, 2025 13:01
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Caution

Inline review comments failed to post. This is likely due to GitHub's limits when posting large numbers of comments.

Actionable comments posted: 3

🧹 Nitpick comments (7)
locales/file-uploader/et.js (1)

120-120: Consider improving the Estonian translation.

The current translation "Ootel {{source}}" is understandable but could be more natural. Consider using one of these alternatives:

  • "Ootab {{source}}" (actively waiting for)
  • "Ootan {{source}}" (waiting for)
-  'waiting-for': 'Ootel {{source}}',
+  'waiting-for': 'Ootab {{source}}',
locales/file-uploader/fi.js (1)

Line range hint 2-2: Consider updating social-source-lang to match locale-id.

The social-source-lang is set to 'en' while locale-id is 'fi'. This seems inconsistent with other locale files where both values match.

-  'social-source-lang': 'en',
+  'social-source-lang': 'fi',
locales/file-uploader/hy.js (1)

120-120: Consider revising the translation to use a neutral form.

The current Armenian translation uses first person ("I am waiting") while other languages use a neutral form. Consider changing "Սպասում եմ" to a more neutral form to maintain consistency across translations.

locales/file-uploader/ka.js (1)

120-120: Consider adjusting the translation perspective.

The Georgian translation uses first person ("I am waiting") while other languages use a more neutral form. Consider changing to a neutral form for consistency across languages:

-  'waiting-for': 'ველოდები {{source}}',
+  'waiting-for': 'ველოდება {{source}}',
locales/file-uploader/cs.js (1)

125-125: Consider using a verb form for consistency.

The Czech translation uses a noun form ("Čekání") while most other languages use a verb form. Consider changing to a verb form for consistency:

-  'waiting-for': 'Čekání na {{source}}',
+  'waiting-for': 'Čeká se na {{source}}',
blocks/ProgressBar/progress-bar.css (2)

Line range hint 15-20: Consider adding transform optimization for better performance.

While the current implementation works, using transform: scaleX() instead of width can provide better performance as it triggers compositing instead of layout recalculation.

Consider this optimization:

  position: absolute;
- width: calc(var(--l-progress-value) * 1%);
+ width: 100%;
  height: 100%;
  background-color: var(--uc-primary);
- transform: translateX(0);
+ transform-origin: left;
+ transform: scaleX(calc(var(--l-progress-value) / 100));
  opacity: 1;
  transition:
-   width 0.6s,
+   transform 0.6s,
    opacity 0.3s;

51-59: Simplify transform calculation in keyframes.

The current calculation calc(100 / var(--l-fake-progress-width) * 100 * 1%) can be simplified.

Consider this simplification:

  @keyframes fake-progress-animation {
    from {
      transform: translateX(-100%);
    }

    to {
-     transform: translateX(calc(100 / var(--l-fake-progress-width) * 100 * 1%));
+     transform: translateX(calc((100 - var(--l-fake-progress-width)) * 1%));
    }
  }
🛑 Comments failed to post (3)
blocks/ProgressBar/ProgressBar.js (2)

31-37: 🛠️ Refactor suggestion

Simplify progress reset logic and fix event listener issues.

The current implementation adds unnecessary complexity and has potential memory leaks.

Consider this simplified implementation:

  if (value === 0 && prevValue > 0) {
-   this.ref.realProgressLine.addEventListener('transitionend', () => {
-     this.style.setProperty('--l-progress-value', this._value.toString());
-   });
-   return;
  }

  this.style.setProperty('--l-progress-value', this._value.toString());

The CSS property can be updated immediately as the transition will handle the animation smoothly.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

      if (value === 0 && prevValue > 0) {
      }

      this.style.setProperty('--l-progress-value', this._value.toString());

22-29: ⚠️ Potential issue

Fix potential memory leaks and race conditions in event handling.

The current implementation has several issues:

  1. Event listeners are added without cleanup, potentially causing memory leaks
  2. Multiple listeners could be added if value changes rapidly
  3. One-time event listeners are not properly cleaned up

Consider this implementation:

  if (value === 100) {
-   this.ref.realProgressLine.addEventListener('transitionend', () => {
-     this.ref.realProgressLine.classList.toggle('uc-progress--hidden', true);
-   });
+   const hideProgress = () => {
+     this.ref.realProgressLine.classList.toggle('uc-progress--hidden', true);
+     this.ref.realProgressLine.removeEventListener('transitionend', hideProgress);
+   };
+   this.ref.realProgressLine.addEventListener('transitionend', hideProgress, { once: true });
  }

  this.ref.fakeProgressLine.classList.toggle('uc-fake-progress--hidden', value !== 0);
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

      if (value === 100) {
        const hideProgress = () => {
          this.ref.realProgressLine.classList.toggle('uc-progress--hidden', true);
          this.ref.realProgressLine.removeEventListener('transitionend', hideProgress);
        };
        this.ref.realProgressLine.addEventListener('transitionend', hideProgress, { once: true });
      }

      this.ref.fakeProgressLine.classList.toggle('uc-fake-progress--hidden', value !== 0);
blocks/ProgressBar/progress-bar.css (1)

30-44: 💡 Codebase verification

Browser compatibility and accessibility improvements needed

  1. Remove or provide fallback for non-standard transition-behavior property
  2. Add reduced motion support:
@media (prefers-reduced-motion: reduce) {
  uc-progress-bar .uc-fake-progress {
    animation-duration: 3s; /* Slower animation */
    /* Or completely disable: animation: none; */
  }
}
  1. Consider using CSS @supports rule for transition-behavior when browser support improves
🔗 Analysis chain

Address browser compatibility and performance concerns.

  1. The transition-behavior property has limited browser support
  2. Continuous animation might impact performance on low-end devices

Run this script to check browser compatibility:

Consider adding:

  1. A fallback for browsers that don't support transition-behavior
  2. will-change: transform for better performance
  3. Reduced animation on reduced-motion preference
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check MDN data for transition-behavior support
curl -s "https://raw.githubusercontent.com/mdn/browser-compat-data/main/css/properties/transition-behavior.json" | jq '.css.properties["transition-behavior"].support'

Length of output: 171


Script:

#!/bin/bash
# Search for transition-behavior usage and animation definitions
echo "=== Searching for transition-behavior usage ==="
rg "transition-behavior" -A 2 -B 2

echo -e "\n=== Searching for animation definitions ==="
rg "@keyframes fake-progress-animation" -A 5 -B 1

Length of output: 933


Script:

#!/bin/bash
# Search for prefers-reduced-motion media query
echo "=== Checking for reduced motion handling ==="
rg "prefers-reduced-motion" -A 2 -B 2

echo -e "\n=== Checking for animation duration/timing variables ==="
rg "animation:.*fake-progress-animation" -A 2 -B 2

Length of output: 643

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Nitpick comments (1)
blocks/ProgressBar/ProgressBar.js (1)

47-50: Enhance accessibility with ARIA attributes.

The progress bar template should include ARIA attributes to improve accessibility.

Consider this enhancement:

  ProgressBar.template = /* HTML */ `
-   <div ref="fakeProgressLine" class="uc-fake-progress"></div>
-   <div ref="realProgressLine" class="uc-progress"></div>
+   <div ref="fakeProgressLine" class="uc-fake-progress" role="progressbar" aria-hidden="true"></div>
+   <div ref="realProgressLine" class="uc-progress" role="progressbar" aria-valuemin="0" aria-valuemax="100" aria-valuenow="0"></div>
  `;

Don't forget to update the aria-valuenow attribute when the progress value changes:

  this.style.setProperty('--l-progress-value', this._value.toString());
+ this.ref.realProgressLine.setAttribute('aria-valuenow', this._value.toString());
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f9a0b1d and 2a4e6d1.

📒 Files selected for processing (38)
  • blocks/FileItem/FileItem.js (6 hunks)
  • blocks/ProgressBar/ProgressBar.js (1 hunks)
  • blocks/ProgressBar/progress-bar.css (3 hunks)
  • locales/file-uploader/ar.js (1 hunks)
  • locales/file-uploader/az.js (1 hunks)
  • locales/file-uploader/ca.js (1 hunks)
  • locales/file-uploader/cs.js (1 hunks)
  • locales/file-uploader/da.js (1 hunks)
  • locales/file-uploader/de.js (1 hunks)
  • locales/file-uploader/el.js (1 hunks)
  • locales/file-uploader/en.js (2 hunks)
  • locales/file-uploader/es.js (1 hunks)
  • locales/file-uploader/et.js (1 hunks)
  • locales/file-uploader/fi.js (1 hunks)
  • locales/file-uploader/fr.js (1 hunks)
  • locales/file-uploader/he.js (1 hunks)
  • locales/file-uploader/hy.js (1 hunks)
  • locales/file-uploader/is.js (1 hunks)
  • locales/file-uploader/it.js (1 hunks)
  • locales/file-uploader/ja.js (1 hunks)
  • locales/file-uploader/ka.js (1 hunks)
  • locales/file-uploader/kk.js (1 hunks)
  • locales/file-uploader/ko.js (1 hunks)
  • locales/file-uploader/lv.js (1 hunks)
  • locales/file-uploader/nb.js (1 hunks)
  • locales/file-uploader/nl.js (1 hunks)
  • locales/file-uploader/pl.js (1 hunks)
  • locales/file-uploader/pt.js (1 hunks)
  • locales/file-uploader/ro.js (1 hunks)
  • locales/file-uploader/ru.js (1 hunks)
  • locales/file-uploader/sk.js (1 hunks)
  • locales/file-uploader/sr.js (1 hunks)
  • locales/file-uploader/sv.js (1 hunks)
  • locales/file-uploader/tr.js (1 hunks)
  • locales/file-uploader/uk.js (1 hunks)
  • locales/file-uploader/vi.js (1 hunks)
  • locales/file-uploader/zh-TW.js (1 hunks)
  • locales/file-uploader/zh.js (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (37)
  • locales/file-uploader/kk.js
  • locales/file-uploader/de.js
  • locales/file-uploader/az.js
  • locales/file-uploader/en.js
  • locales/file-uploader/ka.js
  • locales/file-uploader/ar.js
  • locales/file-uploader/it.js
  • locales/file-uploader/ca.js
  • locales/file-uploader/sk.js
  • locales/file-uploader/sr.js
  • locales/file-uploader/ko.js
  • locales/file-uploader/cs.js
  • locales/file-uploader/zh-TW.js
  • locales/file-uploader/da.js
  • locales/file-uploader/es.js
  • locales/file-uploader/nb.js
  • locales/file-uploader/is.js
  • locales/file-uploader/he.js
  • locales/file-uploader/ru.js
  • locales/file-uploader/et.js
  • locales/file-uploader/sv.js
  • locales/file-uploader/fi.js
  • locales/file-uploader/ro.js
  • locales/file-uploader/pl.js
  • locales/file-uploader/uk.js
  • locales/file-uploader/tr.js
  • locales/file-uploader/vi.js
  • locales/file-uploader/ja.js
  • locales/file-uploader/lv.js
  • locales/file-uploader/nl.js
  • locales/file-uploader/zh.js
  • locales/file-uploader/hy.js
  • locales/file-uploader/pt.js
  • locales/file-uploader/el.js
  • locales/file-uploader/fr.js
  • blocks/FileItem/FileItem.js
  • blocks/ProgressBar/progress-bar.css
🔇 Additional comments (3)
blocks/ProgressBar/ProgressBar.js (3)

28-28: LGTM! Clear and correct visibility toggle logic.

The fake progress line visibility is properly toggled based on the progress value.


37-37: LGTM! Efficient progress value update.

Good use of CSS custom property for progress value updates, which is performant and maintainable.


41-42: Consider potential race condition with completion handler.

While the visibility toggle logic is correct, there could be a race condition if visibility changes while a completion transition is in progress.

Consider adding a check in the completion handler:

  defineAccessor('visible', (visible) => {
    this.ref.realProgressLine.classList.toggle('uc-progress--hidden', !visible);
    this.ref.fakeProgressLine.classList.toggle('uc-fake-progress--hidden', !visible);
+   // Reset completion state when showing
+   if (visible && this._value === 100) {
+     this._value = 0;
+   }
  });

@nd0ut nd0ut force-pushed the fix/from-url-progressbar branch from 2a4e6d1 to 8942c11 Compare January 23, 2025 21:47
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (2)
blocks/ProgressBar/ProgressBar.js (2)

22-32: LGTM! Memory leak fixed, but consider debouncing.

The event listener cleanup is now properly handled with once: true. However, rapid value changes near 100% could still cause visual glitches.

Consider debouncing the transition:

  if (value === 100) {
+   clearTimeout(this._hideTimeout);
+   this._hideTimeout = setTimeout(() => {
      this.ref.realProgressLine.addEventListener(
        'transitionend',
        () => {
          this.ref.realProgressLine.classList.toggle('uc-progress--hidden', true);
        },
        {
          once: true,
        },
      );
+   }, 100);
  }

37-45: LGTM! Memory leak fixed, but consider debouncing.

The event listener cleanup is now properly handled with once: true. However, rapid value changes near 0% could still cause visual glitches.

Consider debouncing the transition similar to the 100% case:

  if (value === 0 && prevValue > 0) {
+   clearTimeout(this._resetTimeout);
+   this._resetTimeout = setTimeout(() => {
      this.ref.realProgressLine.addEventListener(
        'transitionend',
        () => {
          this.style.setProperty('--l-progress-value', this._value.toString());
        },
        {
          once: true,
        },
      );
+   }, 100);
    return;
  }
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 2a4e6d1 and 8942c11.

📒 Files selected for processing (38)
  • blocks/FileItem/FileItem.js (6 hunks)
  • blocks/ProgressBar/ProgressBar.js (1 hunks)
  • blocks/ProgressBar/progress-bar.css (3 hunks)
  • locales/file-uploader/ar.js (1 hunks)
  • locales/file-uploader/az.js (1 hunks)
  • locales/file-uploader/ca.js (1 hunks)
  • locales/file-uploader/cs.js (1 hunks)
  • locales/file-uploader/da.js (1 hunks)
  • locales/file-uploader/de.js (1 hunks)
  • locales/file-uploader/el.js (1 hunks)
  • locales/file-uploader/en.js (2 hunks)
  • locales/file-uploader/es.js (1 hunks)
  • locales/file-uploader/et.js (1 hunks)
  • locales/file-uploader/fi.js (1 hunks)
  • locales/file-uploader/fr.js (1 hunks)
  • locales/file-uploader/he.js (1 hunks)
  • locales/file-uploader/hy.js (1 hunks)
  • locales/file-uploader/is.js (1 hunks)
  • locales/file-uploader/it.js (1 hunks)
  • locales/file-uploader/ja.js (1 hunks)
  • locales/file-uploader/ka.js (1 hunks)
  • locales/file-uploader/kk.js (1 hunks)
  • locales/file-uploader/ko.js (1 hunks)
  • locales/file-uploader/lv.js (1 hunks)
  • locales/file-uploader/nb.js (1 hunks)
  • locales/file-uploader/nl.js (1 hunks)
  • locales/file-uploader/pl.js (1 hunks)
  • locales/file-uploader/pt.js (1 hunks)
  • locales/file-uploader/ro.js (1 hunks)
  • locales/file-uploader/ru.js (1 hunks)
  • locales/file-uploader/sk.js (1 hunks)
  • locales/file-uploader/sr.js (1 hunks)
  • locales/file-uploader/sv.js (1 hunks)
  • locales/file-uploader/tr.js (1 hunks)
  • locales/file-uploader/uk.js (1 hunks)
  • locales/file-uploader/vi.js (1 hunks)
  • locales/file-uploader/zh-TW.js (1 hunks)
  • locales/file-uploader/zh.js (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (37)
  • locales/file-uploader/kk.js
  • locales/file-uploader/de.js
  • locales/file-uploader/da.js
  • locales/file-uploader/el.js
  • locales/file-uploader/tr.js
  • locales/file-uploader/nb.js
  • locales/file-uploader/zh-TW.js
  • locales/file-uploader/nl.js
  • locales/file-uploader/ja.js
  • locales/file-uploader/ar.js
  • locales/file-uploader/zh.js
  • locales/file-uploader/ko.js
  • locales/file-uploader/hy.js
  • locales/file-uploader/it.js
  • locales/file-uploader/az.js
  • locales/file-uploader/fi.js
  • locales/file-uploader/fr.js
  • locales/file-uploader/he.js
  • locales/file-uploader/ca.js
  • locales/file-uploader/sk.js
  • locales/file-uploader/uk.js
  • locales/file-uploader/pt.js
  • locales/file-uploader/is.js
  • locales/file-uploader/vi.js
  • locales/file-uploader/ru.js
  • locales/file-uploader/en.js
  • locales/file-uploader/pl.js
  • locales/file-uploader/ro.js
  • locales/file-uploader/sv.js
  • locales/file-uploader/lv.js
  • locales/file-uploader/cs.js
  • locales/file-uploader/ka.js
  • locales/file-uploader/es.js
  • locales/file-uploader/et.js
  • blocks/FileItem/FileItem.js
  • blocks/ProgressBar/progress-bar.css
  • locales/file-uploader/sr.js
🔇 Additional comments (4)
blocks/ProgressBar/ProgressBar.js (4)

34-34: LGTM! Clear and correct visibility toggle.

The fake progress line visibility logic is appropriate, showing it only during initial loading state.


49-49: LGTM! Clean progress value update.

Using CSS custom properties for progress value is a good practice for performance.


53-54: LGTM! Consistent visibility handling.

Both progress lines are toggled consistently, maintaining visual coherence.


59-62: LGTM! Clean template structure.

The template is minimal and properly structured with appropriate ref attributes.

@nd0ut nd0ut force-pushed the fix/from-url-progressbar branch from 8942c11 to 0264408 Compare February 1, 2025 20:59
@nd0ut nd0ut force-pushed the fix/from-url-progressbar branch from 0264408 to a21f0b1 Compare February 1, 2025 21:00
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 8942c11 and a21f0b1.

📒 Files selected for processing (38)
  • blocks/FileItem/FileItem.js (6 hunks)
  • blocks/ProgressBar/ProgressBar.js (2 hunks)
  • blocks/ProgressBar/progress-bar.css (3 hunks)
  • locales/file-uploader/ar.js (1 hunks)
  • locales/file-uploader/az.js (1 hunks)
  • locales/file-uploader/ca.js (1 hunks)
  • locales/file-uploader/cs.js (1 hunks)
  • locales/file-uploader/da.js (1 hunks)
  • locales/file-uploader/de.js (1 hunks)
  • locales/file-uploader/el.js (1 hunks)
  • locales/file-uploader/en.js (2 hunks)
  • locales/file-uploader/es.js (1 hunks)
  • locales/file-uploader/et.js (1 hunks)
  • locales/file-uploader/fi.js (1 hunks)
  • locales/file-uploader/fr.js (1 hunks)
  • locales/file-uploader/he.js (1 hunks)
  • locales/file-uploader/hy.js (1 hunks)
  • locales/file-uploader/is.js (1 hunks)
  • locales/file-uploader/it.js (1 hunks)
  • locales/file-uploader/ja.js (1 hunks)
  • locales/file-uploader/ka.js (1 hunks)
  • locales/file-uploader/kk.js (1 hunks)
  • locales/file-uploader/ko.js (1 hunks)
  • locales/file-uploader/lv.js (1 hunks)
  • locales/file-uploader/nb.js (1 hunks)
  • locales/file-uploader/nl.js (1 hunks)
  • locales/file-uploader/pl.js (1 hunks)
  • locales/file-uploader/pt.js (1 hunks)
  • locales/file-uploader/ro.js (1 hunks)
  • locales/file-uploader/ru.js (1 hunks)
  • locales/file-uploader/sk.js (1 hunks)
  • locales/file-uploader/sr.js (1 hunks)
  • locales/file-uploader/sv.js (1 hunks)
  • locales/file-uploader/tr.js (1 hunks)
  • locales/file-uploader/uk.js (1 hunks)
  • locales/file-uploader/vi.js (1 hunks)
  • locales/file-uploader/zh-TW.js (1 hunks)
  • locales/file-uploader/zh.js (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (37)
  • locales/file-uploader/is.js
  • locales/file-uploader/az.js
  • locales/file-uploader/ka.js
  • locales/file-uploader/et.js
  • locales/file-uploader/ro.js
  • locales/file-uploader/lv.js
  • locales/file-uploader/vi.js
  • locales/file-uploader/tr.js
  • locales/file-uploader/it.js
  • locales/file-uploader/uk.js
  • locales/file-uploader/fr.js
  • locales/file-uploader/en.js
  • locales/file-uploader/he.js
  • locales/file-uploader/hy.js
  • locales/file-uploader/zh.js
  • locales/file-uploader/sv.js
  • locales/file-uploader/pt.js
  • locales/file-uploader/sr.js
  • locales/file-uploader/da.js
  • locales/file-uploader/fi.js
  • locales/file-uploader/ko.js
  • locales/file-uploader/pl.js
  • locales/file-uploader/es.js
  • locales/file-uploader/cs.js
  • locales/file-uploader/de.js
  • locales/file-uploader/ca.js
  • locales/file-uploader/el.js
  • locales/file-uploader/sk.js
  • locales/file-uploader/ja.js
  • locales/file-uploader/nb.js
  • locales/file-uploader/kk.js
  • blocks/ProgressBar/progress-bar.css
  • locales/file-uploader/ar.js
  • locales/file-uploader/zh-TW.js
  • locales/file-uploader/ru.js
  • locales/file-uploader/nl.js
  • blocks/FileItem/FileItem.js
🔇 Additional comments (5)
blocks/ProgressBar/ProgressBar.js (5)

7-9: LGTM!

The _visible property is well-documented and has a sensible default value.


24-34: LGTM!

The event listener is properly cleaned up using the once option, which addresses the memory leak concerns from previous reviews.


36-36: LGTM!

The fake progress line visibility toggle is correctly implemented.


39-51: LGTM!

The reset handling is properly implemented with cleanup of the event listener using the once option.


63-66: LGTM!

The template structure is clean with properly defined references for both progress lines.

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
blocks/ProgressBar/ProgressBar.js (1)

37-48: Improve reset transition handling.

The reset transition event listener could be enhanced with error handling and cleanup on component destruction.

Consider this implementation:

  if (value === 0 && prevValue > 0) {
+   const handleResetTransition = () => {
+     try {
+       this.style.setProperty('--l-progress-value', this._value.toString());
+     } catch (error) {
+       console.error('Failed to update progress value:', error);
+     }
+   };
+
    this.ref.realProgressLine.addEventListener(
      'transitionend',
-     () => {
-       this.style.setProperty('--l-progress-value', this._value.toString());
-     },
+     handleResetTransition,
      {
        once: true,
      },
    );
+
+   // Cleanup on component destruction
+   this.destructors.push(() => {
+     this.ref.realProgressLine.removeEventListener('transitionend', handleResetTransition);
+   });
    return;
  }
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a21f0b1 and d6321c5.

📒 Files selected for processing (1)
  • blocks/ProgressBar/ProgressBar.js (2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Analyze (javascript)
🔇 Additional comments (4)
blocks/ProgressBar/ProgressBar.js (4)

7-9: LGTM!

The new _visible property is well-documented and has a sensible default value.


19-22: LGTM!

The explicit null/undefined check and visibility optimization are good improvements.


53-58: LGTM!

The visible accessor changes ensure consistent visibility state for both progress lines.


62-65: LGTM!

The template structure clearly separates fake and real progress lines with consistent naming.

@nd0ut nd0ut merged commit 86dfbb1 into main Feb 3, 2025
3 checks passed
@nd0ut nd0ut deleted the fix/from-url-progressbar branch February 3, 2025 11:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants