-
-
Notifications
You must be signed in to change notification settings - Fork 362
fix(Affix): use culture-invariant for position #6796
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
Conversation
Reviewer's guide (collapsed on small PRs)Reviewer's GuideThe 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 generationclassDiagram
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
File-Level Changes
Assessment against linked issues
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this 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
AddStyletoAddClassmethod 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;") |
Copilot
AI
Sep 28, 2025
There was a problem hiding this comment.
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.
| .AddClass($"{Position.ToDescriptionString()}: {Offset.ToString(CultureInfo.InvariantCulture)}px;") | |
| .AddStyle($"{Position.ToDescriptionString()}: {Offset.ToString(CultureInfo.InvariantCulture)}px;") |
There was a problem hiding this 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>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
| .AddClass($"z-index: {ZIndex};", ZIndex.HasValue) | ||
| .AddClass($"{Position.ToDescriptionString()}: {Offset.ToString(CultureInfo.InvariantCulture)}px;") |
There was a problem hiding this comment.
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 Report✅ All modified and coverable lines are covered by tests. 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
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Link issues
fixes #6795
Summary By Copilot
Regression?
Risk
Verification
Packaging changes reviewed?
☑️ Self Check before Merge
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:
Enhancements: