Skip to content

refactor(ScrollToTarget): implement debounced update for active target handling #2404

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

Merged
merged 1 commit into from
May 13, 2025

Conversation

capdiem
Copy link
Contributor

@capdiem capdiem commented May 13, 2025

No description provided.

@capdiem capdiem requested a review from Copilot May 13, 2025 02:18
Copy link
Contributor

@Copilot 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 refactors the ScrollToTarget component to implement a debounced update for active target handling.

  • Updates the manifest to reference the new scroll-to-target JS file
  • Implements debounced updates in both JavaScript and C# components
  • Removes the deprecated duplicate 'lastTarget' field in the C# component

Reviewed Changes

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

Show a summary per file
File Description
src/Masa.Blazor/wwwroot/js/manifest.json Updated file hash reference for scroll-to-target JS file
src/Masa.Blazor/wwwroot/js/components/scroll-to-target/index-d22e7344.js Introduces debounced update wrapping for invoking UpdateActiveTarget
src/Masa.Blazor/wwwroot/js/components/scroll-to-target/index-0c459122.js Removed outdated implementation
src/Masa.Blazor/Components/ScrollToTarget/MScrollToTarget.cs Removes unused field and adds guard on updating active target
src/Masa.Blazor.JS/src/components/scroll-to-target/index.ts Replaces direct call with a debounced update using a debounce utility

internal async ValueTask UpdateActiveTarget(string target)
{
if (_targetContext.ActiveTarget == target)
Copy link
Preview

Copilot AI May 13, 2025

Choose a reason for hiding this comment

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

[nitpick] The method now compares _targetContext.ActiveTarget with the parameter value before updating a separate lastTarget field. To improve maintainability, consider using a single source of truth for the active target state—either consistently update _targetContext or replace its use with lastTarget.

Copilot uses AI. Check for mistakes.

@MayueCif MayueCif merged commit 8bb2ffe into main May 13, 2025
1 check passed
@MayueCif MayueCif deleted the feature/scroll-to-target branch May 13, 2025 02:22
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.

2 participants