Skip to content

Commit 34ad19d

Browse files
πŸ› Fix issue where passed in custom middleware is overridden (#3005)
* πŸ› Fix issue where passed in custom middleware is affected by the defaults due to order * βœ… Update test to reflect options passed as last in the middleware array
1 parent fb73819 commit 34ad19d

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

β€Žshepherd.js/src/utils/floating-ui.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ export function getFloatingUIOptions(
202202
options.placement = attachToOptions.on;
203203
}
204204

205-
return deepmerge(step.options.floatingUIOptions || {}, options);
205+
return deepmerge(options, step.options.floatingUIOptions || {});
206206
}
207207

208208
function addArrow(step: Step) {

β€Žtest/unit/utils/general.spec.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ describe('General Utils', function () {
7676
});
7777

7878
describe('floatingUIOptions', function () {
79-
it('middleware can be overridden', function () {
79+
it('middleware options are passed in last', function () {
8080
const step = new Step(
8181
{},
8282
{
@@ -98,7 +98,8 @@ describe('General Utils', function () {
9898
step.options.attachTo,
9999
step
100100
);
101-
expect(floatingUIOptions.middleware[0].options.altAxis).toBe(false);
101+
// Shepherd pushes in flip and shift by default, so this is 3rd
102+
expect(floatingUIOptions.middleware[2].options.altAxis).toBe(false);
102103
});
103104

104105
it('positioning strategy is explicitly set', function () {

0 commit comments

Comments
Β (0)