Skip to content

Fix: Disable auto-scroll during fade transition to prevent conflicts#165

Open
milindmore22 wants to merge 1 commit into
developfrom
fix/autoscroll-fade
Open

Fix: Disable auto-scroll during fade transition to prevent conflicts#165
milindmore22 wants to merge 1 commit into
developfrom
fix/autoscroll-fade

Conversation

@milindmore22

Copy link
Copy Markdown
Contributor

Summary

This pull request updates the Carousel block to ensure that the Auto Scroll feature is only available and active when the transition is not set to "fade". It adds safeguards in both the editor and view logic, updates tests to reflect the new behavior, and introduces a mock for the auto-scroll plugin in tests.

Feature restriction and UI updates:

  • The Auto Scroll panel and option are now only shown in the editor UI when the transition is not set to 'fade'. If the user selects 'fade', autoScroll is automatically set to false. (src/blocks/carousel/edit.tsx) [1] [2] [3]
  • The block's saved output only includes autoScroll settings if the transition is not 'fade'. (src/blocks/carousel/save.tsx)

Carousel initialization logic:

  • The carousel view logic now prevents the Auto Scroll plugin from being initialized when the transition is 'fade'. (src/blocks/carousel/view.ts)

Testing improvements:

  • Tests have been updated to verify that the Auto Scroll option is hidden/shown appropriately and that the attribute is set/reset as expected. (src/blocks/carousel/__tests__/edit.test.tsx) [1] [2] [3]
  • Added a test to ensure the Auto Scroll plugin is not included when the transition is 'fade', and added a mock for the auto-scroll module. (src/blocks/carousel/__tests__/view.test.ts, tests/js/setup.ts) [1] [2] [3]

Type of change

  • Bug fix
  • New feature
  • Enhancement/refactor
  • Documentation update
  • Test update
  • Build/CI/tooling

Related issue(s)

Closes #162

What changed

  • Disabled Autoscroll when fade transition is selected.

Breaking changes

Does this introduce a breaking change? If yes, describe the impact and migration path below.

  • Yes — migration path:
  • No

Testing

Describe how this was tested.

  • Unit tests
  • Manual testing
  • Cross-browser testing (if UI changes)

Test details:

Screenshots / recordings

If applicable, add screenshots or short recordings.

Checklist

  • I have self-reviewed this PR
  • I have added/updated tests where needed
  • I have updated docs where needed
  • I have checked for breaking changes

Copilot AI review requested due to automatic review settings July 10, 2026 13:54

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Note

Copilot couldn't run its full agentic review because no GitHub Actions runner was available. Make sure your repository has a runner available to run Copilot's review, or add a copilot-setup-steps.yml file specifying one with the runs-on attribute. See the docs for more details.

This PR prevents Carousel Auto Scroll from being enabled/initialized when the transition is set to fade, avoiding plugin conflicts during fade transitions.

Changes:

  • Update editor logic to hide Auto Scroll controls for fade and forcibly disable autoScroll when switching to fade.
  • Update frontend/view initialization to skip the Auto Scroll plugin when transition === 'fade', and adjust saved output accordingly.
  • Add/adjust unit tests and introduce a Jest mock for embla-carousel-auto-scroll.

Reviewed changes

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

Show a summary per file
File Description
tests/js/setup.ts Adds a Jest mock for embla-carousel-auto-scroll to support new view tests.
src/blocks/carousel/view.ts Prevents Auto Scroll plugin initialization when transition is fade.
src/blocks/carousel/save.tsx Stops emitting Auto Scroll settings when transition is fade.
src/blocks/carousel/edit.tsx Hides Auto Scroll panel for fade and disables autoScroll when switching to fade.
src/blocks/carousel/__tests__/view.test.ts Adds a test asserting Auto Scroll isn’t included for fade transitions.
src/blocks/carousel/__tests__/edit.test.tsx Updates editor tests to reflect UI/attribute changes around Auto Scroll and fade.

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

Comment thread tests/js/setup.ts
Comment on lines +67 to +78
jest.mock( 'embla-carousel-auto-scroll', () => ( {
__esModule: true,
default: jest.fn( () => ( {
name: 'autoScroll',
options: {},
init: jest.fn(),
destroy: jest.fn(),
play: jest.fn(),
stop: jest.fn(),
isPlaying: jest.fn( () => false ),
} ) ),
} ) );
Comment on lines +957 to +962
const lastCall = ( EmblaCarousel as unknown as jest.Mock ).mock.calls.at( -1 );
expect( lastCall?.[ 2 ] ).toContainEqual( ( Fade as unknown as jest.Mock ).mock.results.at( -1 )?.value );
const autoScrollMockResult = ( AutoScroll as unknown as jest.Mock ).mock.results.at( -1 )?.value;
if ( autoScrollMockResult ) {
expect( lastCall?.[ 2 ] ).not.toContainEqual( autoScrollMockResult );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Fading transition does not work for forward and backward directions.

2 participants