-
-
Notifications
You must be signed in to change notification settings - Fork 365
feat(SlideButton): support prefers-reduced-motion css #7166
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 GuideAdds 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 motionflowchart 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)"]
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.
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>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
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
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: reduceis 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 Report✅ All modified and coverable lines are covered by tests. 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
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 #7165
Summary By Copilot
Regression?
Risk
Verification
Packaging changes reviewed?
☑️ Self Check before Merge
Summary by Sourcery
Improve SlideButton dropdown behavior and accessibility around animated slide transitions.
Enhancements: