Apply BitCarousel improvements (#12881) - #12882
Conversation
WalkthroughBitCarousel adds accessibility semantics, expanded navigation and autoplay behavior, vertical and fade layouts, configurable styling, public state and control APIs, comprehensive tests, and new documentation and demo samples. ChangesCarousel improvements
Estimated code review effort: 4 (Complex) | ~60 minutes Sequence Diagram(s)sequenceDiagram
participant Browser
participant BitCarousel
participant Timer
participant Consumer
Browser->>BitCarousel: Send interaction event
BitCarousel->>BitCarousel: Calculate and validate target page
BitCarousel->>Timer: Pause, restart, or stop autoplay
BitCarousel->>Consumer: Invoke OnChange for a changed page
Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 6
🧹 Nitpick comments (3)
src/BlazorUI/Tests/Bit.BlazorUI.Tests/Components/Lists/Carousel/BitCarouselTests.cs (1)
438-449: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueRemove the unnecessary async from this test.
The test body has no real await.
await Task.CompletedTask;exists only to satisfy theasync Tasksignature. Make the method synchronous.♻️ Proposed change
[TestMethod] - public async Task BitCarouselShouldRespectDefaultPage() + public void BitCarouselShouldRespectDefaultPage() { var component = RenderComponent<BitCarouselTest>(parameters => { parameters.Add(p => p.DefaultPage, 2); }); component.WaitForAssertion(() => Assert.AreEqual(1, component.Instance.Carousel.CurrentPage)); - - await Task.CompletedTask; }🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/BlazorUI/Tests/Bit.BlazorUI.Tests/Components/Lists/Carousel/BitCarouselTests.cs` around lines 438 - 449, Update BitCarouselShouldRespectDefaultPage to be a synchronous test method returning void, and remove the unnecessary await Task.CompletedTask statement.src/BlazorUI/Bit.BlazorUI/Components/Lists/Carousel/BitCarousel.razor.cs (1)
754-796: 🎯 Functional Correctness | 🔵 Trivial | 💤 Low valueItem layout is skipped when the bounding rect is null.
The whole per-item loop sits inside
if (rect is not null). When the JS call returns null (prerendering, or an element that is not yet measurable), the items keep the styles of the previous layout. After a switch to or fromFade, this leaves staleInternalTransformStyleorInternalFadeStylevalues on the items. Consider resetting the fade and transform state before the measurement, so a failed measurement does not leave a mixed layout.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/BlazorUI/Bit.BlazorUI/Components/Lists/Carousel/BitCarousel.razor.cs` around lines 754 - 796, Reset each item’s InternalTransformStyle and InternalFadeStyle before calling _js.BitUtilsGetBoundingClientRect, ensuring stale Fade or transform styles are cleared even when the measurement returns null. Keep the existing measured-layout assignments in the per-item loop unchanged when rect is available.src/BlazorUI/Bit.BlazorUI/Components/Lists/Carousel/BitCarouselItem.razor.cs (1)
105-105: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueRemove the unused
Refresh()method. No caller exists forBitCarouselItem.Refresh().🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/BlazorUI/Bit.BlazorUI/Components/Lists/Carousel/BitCarouselItem.razor.cs` at line 105, Remove the unused BitCarouselItem.Refresh() method, including its StateHasChanged() implementation, since no callers depend on it.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/BlazorUI/Bit.BlazorUI/Components/Lists/Carousel/BitCarousel.razor`:
- Line 26: Update the BitCarousel pointer-down handling so default prevention
applies only when the event originates from the slide area, not child controls
such as next/previous buttons. Move the conditional prevention into
HandlePointerDown (using the event target and existing JS interop as
appropriate) and remove the unconditional `@onpointerdown`:preventDefault behavior
from the container.
- Around line 63-69: Update the controls group markup in BitCarousel so
aria-label uses DotsAriaLabel only when the dots render; when only the AutoPlay
and ShowPlayPause control is present, omit the dots label or provide the
appropriate play/pause grouping label. Preserve the existing rendering condition
and class/style behavior.
In `@src/BlazorUI/Bit.BlazorUI/Components/Lists/Carousel/BitCarousel.razor.cs`:
- Around line 920-1024: Keep _navigating set throughout the full non-fade
transition, including the transform updates and ApplyNewIndices call. Move its
reset from the delay’s finally block to a finally block surrounding the
remaining animation work and ApplyNewIndices, ensuring it is cleared even on
failure while concurrent Go calls remain blocked until completion.
- Around line 471-487: Update BitCarousel’s Pause and Resume methods to trigger
StateHasChanged after changing playback state so the button icon,
PauseButtonAriaLabel, and aria-live attribute refresh immediately. Prefer
centralizing this state update in UpdateAutoPlayTimer and remove TogglePlay’s
redundant StateHasChanged call if that method becomes responsible for the
refresh.
- Around line 1242-1252: Update ShouldAutoPlay so it returns true only when the
carousel has more than one page; remove the _allItems.Count == 0 condition. Keep
the existing enablement, pause, hover, and focus checks unchanged, relying on
UpdateAutoPlayTimer from RegisterItem or OnParametersSet when items become
available.
In
`@src/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Pages/Components/Lists/Carousel/BitCarouselDemo.razor`:
- Around line 204-221: Update every carousel image in the rendered demos and
copied Razor samples with an appropriate alt attribute, using descriptive text
for meaningful images or alt="" for decorative images. Apply this to the
AutoPlay, Vertical, Fade, and External Icons examples in BitCarouselDemo.razor
and the corresponding sample content in BitCarouselDemo.razor.samples.cs,
keeping matching markup aligned across both files: BitCarouselDemo.razor ranges
204-221, 273-290, and 301-318; BitCarouselDemo.razor.samples.cs ranges 173-217,
261-299, and 336-391.
---
Nitpick comments:
In `@src/BlazorUI/Bit.BlazorUI/Components/Lists/Carousel/BitCarousel.razor.cs`:
- Around line 754-796: Reset each item’s InternalTransformStyle and
InternalFadeStyle before calling _js.BitUtilsGetBoundingClientRect, ensuring
stale Fade or transform styles are cleared even when the measurement returns
null. Keep the existing measured-layout assignments in the per-item loop
unchanged when rect is available.
In
`@src/BlazorUI/Bit.BlazorUI/Components/Lists/Carousel/BitCarouselItem.razor.cs`:
- Line 105: Remove the unused BitCarouselItem.Refresh() method, including its
StateHasChanged() implementation, since no callers depend on it.
In
`@src/BlazorUI/Tests/Bit.BlazorUI.Tests/Components/Lists/Carousel/BitCarouselTests.cs`:
- Around line 438-449: Update BitCarouselShouldRespectDefaultPage to be a
synchronous test method returning void, and remove the unnecessary await
Task.CompletedTask statement.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: b6caecbe-a1b3-43f1-aee7-36b7f4e6f966
📒 Files selected for processing (12)
src/BlazorUI/Bit.BlazorUI/Components/Lists/Carousel/BitCarousel.razorsrc/BlazorUI/Bit.BlazorUI/Components/Lists/Carousel/BitCarousel.razor.cssrc/BlazorUI/Bit.BlazorUI/Components/Lists/Carousel/BitCarousel.scsssrc/BlazorUI/Bit.BlazorUI/Components/Lists/Carousel/BitCarouselClassStyles.cssrc/BlazorUI/Bit.BlazorUI/Components/Lists/Carousel/BitCarouselItem.razorsrc/BlazorUI/Bit.BlazorUI/Components/Lists/Carousel/BitCarouselItem.razor.cssrc/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Pages/Components/Lists/Carousel/BitCarouselDemo.razorsrc/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Pages/Components/Lists/Carousel/BitCarouselDemo.razor.cssrc/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Pages/Components/Lists/Carousel/BitCarouselDemo.razor.samples.cssrc/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Pages/Components/Lists/Carousel/BitCarouselDemo.razor.scsssrc/BlazorUI/Tests/Bit.BlazorUI.Tests/Components/Lists/Carousel/BitCarouselTest.razorsrc/BlazorUI/Tests/Bit.BlazorUI.Tests/Components/Lists/Carousel/BitCarouselTests.cs
|
@coderabbitai full-review |
|
✅ Action performedFull review finished. |
There was a problem hiding this comment.
Actionable comments posted: 3
🧹 Nitpick comments (2)
src/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Pages/Components/Lists/Carousel/BitCarouselDemo.razor.cs (1)
78-88: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winDocument and demonstrate
AriaLabelconsistently.The Basic description tells users to set
AriaLabel, but the API table and copied sample omit it.
src/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Pages/Components/Lists/Carousel/BitCarouselDemo.razor.cs#L78-L88: Add anAriaLabelparameter entry with its default value and purpose.src/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Pages/Components/Lists/Carousel/BitCarouselDemo.razor#L18-L24: Set a meaningfulAriaLabelon the Basic carousel.src/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Pages/Components/Lists/Carousel/BitCarouselDemo.razor.samples.cs#L21-L38: Mirror the renderedAriaLabelin the copied Razor sample.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Pages/Components/Lists/Carousel/BitCarouselDemo.razor.cs` around lines 78 - 88, Document and demonstrate the Carousel AriaLabel consistently: in BitCarouselDemo.razor.cs, add an AriaLabel API-table entry with its default value and purpose; in BitCarouselDemo.razor, set a meaningful AriaLabel on the Basic carousel; and in BitCarouselDemo.razor.samples.cs, mirror that attribute in the copied Razor sample. Affected sites: BitCarouselDemo.razor.cs lines 78-88, BitCarouselDemo.razor lines 18-24, and BitCarouselDemo.razor.samples.cs lines 21-38.src/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Pages/Components/Lists/Carousel/BitCarouselDemo.razor.scss (1)
62-62: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winSuppress the Stylelint warning for the two
::deepselectors.Add
/* stylelint-disable-next-line selector-pseudo-element-no-unknown */before the.gap-itemand.custom-itemrules. This matches the repository convention.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Pages/Components/Lists/Carousel/BitCarouselDemo.razor.scss` at line 62, Add the repository-standard stylelint suppression comment immediately before both the `::deep .gap-item` and `::deep .custom-item` selectors, using the `selector-pseudo-element-no-unknown` rule.Source: Linters/SAST tools
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/BlazorUI/Bit.BlazorUI/Components/Lists/Carousel/BitCarousel.razor.cs`:
- Around line 706-716: Update the local variable declaration in
RegisterPreventDefaultsAsync so keys is explicitly typed as string[], allowing
the empty-array branch of the conditional to compile while preserving the
existing key selection behavior.
In
`@src/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Pages/Components/Lists/Carousel/BitCarouselDemo.razor`:
- Around line 227-238: Update the carousel example in BitCarouselDemo.razor at
lines 227-238 to demonstrate StopOnLastSlide with InfiniteScrolling disabled, or
remove the StopOnLastSlide explanation and retain only AutoPlayReverse; then
apply the identical change to the copied sample in
BitCarouselDemo.razor.samples.cs at lines 219-224 so both examples remain
aligned.
In
`@src/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Pages/Components/Lists/Carousel/BitCarouselDemo.razor.samples.cs`:
- Around line 253-257: Update the copied `.gap-item` style in the Gap sample to
include the same `box-sizing: border-box` declaration as the rendered demo,
preserving the existing height rule.
---
Nitpick comments:
In
`@src/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Pages/Components/Lists/Carousel/BitCarouselDemo.razor.cs`:
- Around line 78-88: Document and demonstrate the Carousel AriaLabel
consistently: in BitCarouselDemo.razor.cs, add an AriaLabel API-table entry with
its default value and purpose; in BitCarouselDemo.razor, set a meaningful
AriaLabel on the Basic carousel; and in BitCarouselDemo.razor.samples.cs, mirror
that attribute in the copied Razor sample. Affected sites:
BitCarouselDemo.razor.cs lines 78-88, BitCarouselDemo.razor lines 18-24, and
BitCarouselDemo.razor.samples.cs lines 21-38.
In
`@src/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Pages/Components/Lists/Carousel/BitCarouselDemo.razor.scss`:
- Line 62: Add the repository-standard stylelint suppression comment immediately
before both the `::deep .gap-item` and `::deep .custom-item` selectors, using
the `selector-pseudo-element-no-unknown` rule.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: f8a9662e-3caa-4c04-931a-3b80ac095f3e
📒 Files selected for processing (14)
src/BlazorUI/Bit.BlazorUI/Components/Lists/Carousel/BitCarousel.razorsrc/BlazorUI/Bit.BlazorUI/Components/Lists/Carousel/BitCarousel.razor.cssrc/BlazorUI/Bit.BlazorUI/Components/Lists/Carousel/BitCarousel.scsssrc/BlazorUI/Bit.BlazorUI/Components/Lists/Carousel/BitCarouselClassStyles.cssrc/BlazorUI/Bit.BlazorUI/Components/Lists/Carousel/BitCarouselItem.razorsrc/BlazorUI/Bit.BlazorUI/Components/Lists/Carousel/BitCarouselItem.razor.cssrc/BlazorUI/Bit.BlazorUI/Extensions/JsInterop/UtilsJsRuntimeExtensions.cssrc/BlazorUI/Bit.BlazorUI/Scripts/Utils.tssrc/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Pages/Components/Lists/Carousel/BitCarouselDemo.razorsrc/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Pages/Components/Lists/Carousel/BitCarouselDemo.razor.cssrc/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Pages/Components/Lists/Carousel/BitCarouselDemo.razor.samples.cssrc/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Pages/Components/Lists/Carousel/BitCarouselDemo.razor.scsssrc/BlazorUI/Tests/Bit.BlazorUI.Tests/Components/Lists/Carousel/BitCarouselTest.razorsrc/BlazorUI/Tests/Bit.BlazorUI.Tests/Components/Lists/Carousel/BitCarouselTests.cs
|
Want your agent to iterate on Greptile's feedback? Start a greploop in Claude Code and it will work through the open comments and keep going until this PR reviews clean. |
closes #12881
Summary by CodeRabbit
New Features
Bug Fixes
Documentation
Greptile Summary
The PR substantially expands
BitCarouselwith additional navigation modes, playback controls, accessibility behavior, responsive layouts, styling options, and updated demonstrations and tests.Confidence Score: 5/5
The PR appears safe to merge.
No blocking failure remains.
Important Files Changed
Reviews (4): Last reviewed commit: "resolve review comments 2" | Re-trigger Greptile