Skip to content

Conversation

@ArgoZhang
Copy link
Member

@ArgoZhang ArgoZhang commented Sep 28, 2025

Link issues

fixes #6795

Summary By Copilot

Regression?

  • Yes
  • No

Risk

  • High
  • Medium
  • Low

Verification

  • Manual (required)
  • Automated

Packaging changes reviewed?

  • Yes
  • No
  • N/A

☑️ Self Check before Merge

⚠️ Please check all items below before review. ⚠️

  • Doc is updated/provided or not needed
  • Demo is updated/provided or not needed
  • Merge the latest code from the main branch

Summary by Sourcery

Use culture-invariant formatting for the Affix component's position offset and refactor its style builder to apply inline styles via AddClass.

Bug Fixes:

  • Ensure Offset is converted to string using CultureInfo.InvariantCulture for consistent CSS pixel values

Enhancements:

  • Replace AddStyle calls with AddClass for setting inline z-index and position styles in Affix
  • Add System.Globalization import to support invariant culture formatting

Copilot AI review requested due to automatic review settings September 28, 2025 01:24
@bb-auto bb-auto bot added the bug Something isn't working label Sep 28, 2025
@bb-auto bb-auto bot added this to the 9.10.0 milestone Sep 28, 2025
@sourcery-ai
Copy link
Contributor

sourcery-ai bot commented Sep 28, 2025

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

The PR refactors the Affix component’s style builder to generate CSS rules via AddClass and enforces invariant culture when formatting the Offset value, ensuring consistent styling across different locales.

Class diagram for updated Affix component style generation

classDiagram
    class Affix {
        +int? ZIndex
        +int Offset
        +Position Position
        +IDictionary<string, object>? AdditionalAttributes
        -string? StyleString
    }
    class CssBuilder {
        +AddClass(string, bool)
        +AddStyleFromAttributes(IDictionary<string, object>?)
        +Build()
    }
    Affix --> CssBuilder : uses
    Affix : StyleString uses AddClass for z-index and position
    Affix : Offset formatted with CultureInfo.InvariantCulture
    class CultureInfo {
        +InvariantCulture
    }
    Affix --> CultureInfo : uses for Offset formatting
Loading

File-Level Changes

Change Details Files
Apply culture-invariant formatting to Offset in the position style
  • Imported System.Globalization
  • Switched Offset.ToString() to use CultureInfo.InvariantCulture
src/BootstrapBlazor/Components/Affix/Affix.razor.cs
Replace AddStyle calls with AddClass for z-index and position properties
  • Changed AddStyle("z-index", …) to AddClass("z-index: …") when ZIndex.HasValue
  • Replaced AddStyle(Position.ToDescriptionString(), …) with AddClass using the formatted offset string
src/BootstrapBlazor/Components/Affix/Affix.razor.cs

Assessment against linked issues

Issue Objective Addressed Explanation
#6795 Ensure that position values in the Affix component use culture-invariant formatting.

Possibly linked issues


Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@ArgoZhang ArgoZhang merged commit 7c9a31d into main Sep 28, 2025
4 of 5 checks passed
@ArgoZhang ArgoZhang deleted the perf-style branch September 28, 2025 01:25
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

Fixes a culture-specific number formatting issue in the Affix component by ensuring position values are formatted using invariant culture. This prevents potential layout issues in locales that use different decimal separators.

  • Replace string interpolation with culture-invariant formatting for position offset values
  • Switch from AddStyle to AddClass method calls (appears to be an error)

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

.AddStyle("z-index", $"{ZIndex}", ZIndex.HasValue)
.AddStyle(Position.ToDescriptionString(), $"{Offset}px")
.AddClass($"z-index: {ZIndex};", ZIndex.HasValue)
.AddClass($"{Position.ToDescriptionString()}: {Offset.ToString(CultureInfo.InvariantCulture)}px;")
Copy link

Copilot AI Sep 28, 2025

Choose a reason for hiding this comment

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

The method calls should be AddStyle instead of AddClass. CSS styles should be added using the style methods, not class methods. This will likely result in incorrect CSS output.

Suggested change
.AddClass($"{Position.ToDescriptionString()}: {Offset.ToString(CultureInfo.InvariantCulture)}px;")
.AddStyle($"{Position.ToDescriptionString()}: {Offset.ToString(CultureInfo.InvariantCulture)}px;")

Copilot uses AI. Check for mistakes.
Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey there - I've reviewed your changes and they look great!

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location> `src/BootstrapBlazor/Components/Affix/Affix.razor.cs:45-46` </location>
<code_context>
     private string? StyleString => CssBuilder.Default("position: sticky;")
-        .AddStyle("z-index", $"{ZIndex}", ZIndex.HasValue)
-        .AddStyle(Position.ToDescriptionString(), $"{Offset}px")
+        .AddClass($"z-index: {ZIndex};", ZIndex.HasValue)
+        .AddClass($"{Position.ToDescriptionString()}: {Offset.ToString(CultureInfo.InvariantCulture)}px;")
         .AddStyleFromAttributes(AdditionalAttributes)
         .Build();
</code_context>

<issue_to_address>
**issue (bug_risk):** Switching from AddStyle to AddClass for inline styles may cause rendering issues.

AddClass is intended for CSS class names, not inline style properties. Using it for styles like z-index and offsets may result in incorrect rendering unless CssBuilder explicitly supports this pattern. Revert to AddStyle unless you have verified compatibility.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment on lines +45 to +46
.AddClass($"z-index: {ZIndex};", ZIndex.HasValue)
.AddClass($"{Position.ToDescriptionString()}: {Offset.ToString(CultureInfo.InvariantCulture)}px;")
Copy link
Contributor

Choose a reason for hiding this comment

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

issue (bug_risk): Switching from AddStyle to AddClass for inline styles may cause rendering issues.

AddClass is intended for CSS class names, not inline style properties. Using it for styles like z-index and offsets may result in incorrect rendering unless CssBuilder explicitly supports this pattern. Revert to AddStyle unless you have verified compatibility.

@codecov
Copy link

codecov bot commented Sep 28, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (c183310) to head (3c2727d).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff            @@
##              main     #6796   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files          739       739           
  Lines        31743     31743           
  Branches      4467      4467           
=========================================
  Hits         31743     31743           
Flag Coverage Δ
BB 100.00% <100.00%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug(Affix): use culture-invariant for position

2 participants