Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@sfc-gh-smohile
Copy link
Contributor

Describe your changes

Fixes #11720 where on moving away from current window, the timer pauses. Now we use system time to compare and update timer accordingly instead of using set interval.

GitHub Issue Link (if applicable)

#11720

Testing Plan

  • Explanation of why no additional tests are needed
  • Unit Tests (JS and/or Python) ✅
  • E2E Tests
  • Any manual testing needed?
    Yes, done by me.

Contribution License Agreement

By submitting this pull request you agree that all contributions to this project are made under the Apache 2.0 license.

@sfc-gh-smohile sfc-gh-smohile self-assigned this Jun 24, 2025
@snyk-io
Copy link
Contributor

snyk-io bot commented Jun 24, 2025

🎉 Snyk checks have passed. No issues have been found so far.

security/snyk check is complete. No issues have been found. (View Details)

license/snyk check is complete. No issues have been found. (View Details)

@github-actions
Copy link
Contributor

github-actions bot commented Jun 24, 2025

✅ PR preview is ready!

Name Link
📦 Wheel file https://core-previews.s3-us-west-2.amazonaws.com/pr-11756/streamlit-1.45.1-py3-none-any.whl
🕹️ Preview app pr-11756.streamlit.app (☁️ Deploy here if not accessible)

@sfc-gh-smohile sfc-gh-smohile added security-assessment-completed Security assessment has been completed for PR change:bugfix PR contains bug fix implementation impact:users PR changes affect end users labels Jun 24, 2025
Copy link
Collaborator

@lukasmasuch lukasmasuch left a comment

Choose a reason for hiding this comment

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

LGTM 👍

@sfc-gh-bnisco sfc-gh-bnisco requested a review from Copilot June 24, 2025 20:36
Copy link
Contributor

Copilot AI left a comment

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 fixes a timer bug by switching from an interval-based timer to one that computes elapsed time using the system clock. Key changes include:

  • Adding a useRef hook to record the initial start time.
  • Updating the timer calculation to rely on system time instead of incremental state updates.
  • Enhancing tests in the Spinner component to verify the new timer behavior.

Reviewed Changes

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

File Description
frontend/lib/src/components/elements/Spinner/Spinner.tsx Updated timer logic to compute elapsed time using Date.now() and useRef
frontend/lib/src/components/elements/Spinner/Spinner.test.tsx Added tests using fake timers to verify timer updates based on system time
Comments suppressed due to low confidence (1)

frontend/lib/src/components/elements/Spinner/Spinner.tsx:40

  • [nitpick] Consider renaming 'startTimeRef' to 'initialTimeRef' to more clearly indicate that it stores the time when the component mounts.
  const startTimeRef = useRef<number | null>(null)

@sfc-gh-bnisco sfc-gh-bnisco merged commit a80de2a into develop Jun 24, 2025
37 checks passed
@sfc-gh-bnisco sfc-gh-bnisco deleted the fix/st.spinner_time_fix branch June 24, 2025 21:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

change:bugfix PR contains bug fix implementation impact:users PR changes affect end users security-assessment-completed Security assessment has been completed for PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

st.spinner time count pauses when you move away

4 participants