Skip to content

Conversation

@ArgoZhang
Copy link
Member

@ArgoZhang ArgoZhang commented Nov 23, 2025

Link issues

fixes #7165

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

Improve SlideButton dropdown behavior and accessibility around animated slide transitions.

Enhancements:

  • Adjust SlideButton slide list scrolling state based on transition lifecycle to avoid scrolling during size animations.
  • Honor user prefers-reduced-motion settings by disabling slide-list CSS transitions when reduced motion is requested.

Copilot AI review requested due to automatic review settings November 23, 2025 05:43
@bb-auto bb-auto bot added the enhancement New feature or request label Nov 23, 2025
@bb-auto bb-auto bot added this to the 10.0.0 milestone Nov 23, 2025
@sourcery-ai
Copy link
Contributor

sourcery-ai bot commented Nov 23, 2025

Reviewer's Guide

Adds support for prefers-reduced-motion in the SlideButton component by disabling CSS transitions when users request reduced motion and adjusts JavaScript behavior to manage scroll behavior during slide list transitions.

Flow diagram for SlideButton transition event handling and reduced motion

flowchart TD
    A["User clicks slide button"] --> B["Toggle 'show' class on '.slide-list'"]
    B --> C{"'prefers-reduced-motion: reduce' matched?"}

    C -- "Yes (reduced motion)" --> D["CSS 'transition' is disabled for '.slide-list' ('transition: none')"]
    D --> E["No 'transitionstart' / 'transitionend' events for height/width"]
    E --> F["'.slide-body' 'scroll' class remains unchanged by transition handlers"]

    C -- "No (normal motion)" --> G["CSS 'transition' runs on 'height'/'width'"]
    G --> H["'transitionstart' event fired on '.slide-list'"]
    H --> I{"Event 'propertyName' is 'height' or 'width'?"}
    I -- "No" --> J["Ignore event"]
    I -- "Yes" --> K["Remove 'scroll' class from '.slide-body' during transition"]

    G --> L["'transitionend' event fired on '.slide-list'"]
    L --> M{"Event 'propertyName' is 'height' or 'width'?"}
    M -- "No" --> N["Ignore event"]
    M -- "Yes" --> O{"'.slide-list' has 'show' class?"}
    O -- "Yes" --> P["Add 'scroll' class to '.slide-body' to enable scrolling"]
    O -- "No" --> Q["Leave 'scroll' class removed (list closed)"]
Loading

File-Level Changes

Change Details Files
Control scroll behavior of the slide list body in sync with height/width transitions.
  • Cache the slide body element in the SlideButton initializer
  • Listen for transitionstart on the slide list and remove the scroll class from the slide body when height/width transitions begin
  • Listen for transitionend on the slide list and, if the list is shown, add the scroll class back to the slide body
  • Keep existing click handler on the slide button and close button behavior unchanged
src/BootstrapBlazor/Components/Button/SlideButton.razor.js
Honor the user's prefers-reduced-motion setting for the slide list transition.
  • Define a media query for prefers-reduced-motion: reduce
  • Disable transitions on the slide list within that media query using transition: none !important
  • Normalize the SCSS file header to use a standard @use directive without BOM
src/BootstrapBlazor/Components/Button/SlideButton.razor.scss

Assessment against linked issues

Issue Objective Addressed Explanation
#7165 Add prefers-reduced-motion CSS support to the SlideButton component so that its slide animation/transition is reduced or disabled when the user has enabled reduced motion preferences.

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

sourcery-ai[bot]
sourcery-ai bot previously approved these changes Nov 23, 2025
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 - here's some feedback:

  • In init, consider guarding against a missing '.slide-body' element before calling classList methods to avoid potential runtime errors if the markup changes or is used in a different context.
  • With prefers-reduced-motion disabling transitions, the transitionstart/transitionend handlers will not fire, so you may want to explicitly set the 'scroll' class on '.slide-body' based on the initial/updated state of '.slide-list' when reduced motion is active.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- In init, consider guarding against a missing '.slide-body' element before calling classList methods to avoid potential runtime errors if the markup changes or is used in a different context.
- With prefers-reduced-motion disabling transitions, the transitionstart/transitionend handlers will not fire, so you may want to explicitly set the 'scroll' class on '.slide-body' based on the initial/updated state of '.slide-list' when reduced motion is active.

## Individual Comments

### Comment 1
<location> `src/BootstrapBlazor/Components/Button/SlideButton.razor.js:12-21` </location>
<code_context>
     }
     const button = el.querySelector('.btn-slide')
     const list = el.querySelector('.slide-list')
+    const listBody = el.querySelector('.slide-body')
     const slide = { el, button, list }
     Data.set(id, slide);
     reset(slide)

     EventHandler.on(button, 'click', () => {
         list.classList.toggle('show')
-    })
+    });
+
+    EventHandler.on(list, 'transitionstart', e => {
+        if (e.propertyName !== 'height' && e.propertyName !== 'width') {
+            return;
+        }
+
+        listBody.classList.remove('scroll');
+    });
+    EventHandler.on(list, 'transitionend', e => {
</code_context>

<issue_to_address>
**issue:** Guard against a missing `.slide-body` element before accessing `listBody.classList`.

If `.slide-body` is missing, `listBody` will be `null` and the transition handlers will throw when accessing `listBody.classList`. Consider returning early in `init` when `!listBody`, or add a null check in each handler before modifying the class list.
</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.

Copilot finished reviewing on behalf of ArgoZhang November 23, 2025 05:44
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

This PR adds accessibility support for users who prefer reduced motion by implementing CSS prefers-reduced-motion media query handling in the SlideButton component. The changes also introduce scroll class management during slide transitions.

Key Changes:

  • Added CSS media query to disable transitions when prefers-reduced-motion: reduce is set
  • Implemented transition event handlers to manage scroll behavior on the slide body element

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
src/BootstrapBlazor/Components/Button/SlideButton.razor.scss Added @media (prefers-reduced-motion: reduce) rule to disable transitions for accessibility
src/BootstrapBlazor/Components/Button/SlideButton.razor.js Added transitionstart and transitionend event handlers to manage scroll class on slide body during animations

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@codecov
Copy link

codecov bot commented Nov 23, 2025

Codecov Report

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

Additional details and impacted files
@@            Coverage Diff            @@
##              main     #7166   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files          745       745           
  Lines        32569     32569           
  Branches      4513      4513           
=========================================
  Hits         32569     32569           
Flag Coverage Δ
BB 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.

@ArgoZhang ArgoZhang merged commit 58d3c27 into main Nov 23, 2025
5 checks passed
@ArgoZhang ArgoZhang deleted the feat-slidebutton branch November 23, 2025 06:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(SlideButton): support prefers-reduced-motion css

2 participants