Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/BootstrapBlazor/Components/Affix/Affix.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
// See the LICENSE file in the project root for more information.
// Maintainer: Argo Zhang([email protected]) Website: https://www.blazor.zone

using System.Globalization;

namespace BootstrapBlazor.Components;

/// <summary>
Expand Down Expand Up @@ -40,8 +42,8 @@ public partial class Affix
.Build();

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;")
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.
Comment on lines +45 to +46
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.

.AddStyleFromAttributes(AdditionalAttributes)
.Build();
}
Loading