shepherd icon indicating copy to clipboard operation
shepherd copied to clipboard

Middleware deduping

Open patrikholcak opened this issue 1 year ago • 5 comments

About

This might be a controversial (and breaking) change, but instead of overriding middlewares, I think the step middleware should always win. Feel free to close this PR or message me to make changes.

Take this example:

const defaultStepOptions = {
  floatingUIOptions: {
    middleware: [offset({ crossAxis: 32 })]
  }
};

const stepOptions = {
  floatingUIOptions: {
    middleware: [offset({ crossAxis: -32 })]
  }
}

To override defaultStepOptions you need equal negative spacing and sync these two numbers every time the default changes (or have a constant)

With this PR:

const defaultStepOptions = {
  floatingUIOptions: {
    middleware: [offset({ crossAxis: 32 })]
  }
};

const stepOptions = {
  floatingUIOptions: {
    middleware: [offset({ crossAxis: 0 })]
  }
}

The step offset middleware overrides the default step middleware

patrikholcak avatar Oct 11 '24 17:10 patrikholcak

The latest updates on your projects. Learn more about Vercel for Git ā†—ļøŽ

Name Status Preview Comments Updated (UTC)
shepherd-docs āœ… Ready (Inspect) Visit Preview šŸ’¬ Add feedback Oct 16, 2024 8:37am
shepherd-landing āœ… Ready (Inspect) Visit Preview šŸ’¬ Add feedback Oct 16, 2024 8:37am

vercel[bot] avatar Oct 11 '24 17:10 vercel[bot]

@patrikholcak is attempting to deploy a commit to the shipshapecode Team on Vercel.

A member of the Team first needs to authorize it.

vercel[bot] avatar Oct 11 '24 17:10 vercel[bot]

@patrikholcak we have been talking about this recently and I recently released a change that changes the ordering, so that a dup added in would run last, but that still could have issues. This would be onus on the user to make sure they still have sane defaults when going down this path, but does give the most control.

chuckcarpenter avatar Oct 11 '24 18:10 chuckcarpenter

@patrikholcak docs failed to build due to this error

image

chuckcarpenter avatar Oct 11 '24 18:10 chuckcarpenter

Rebased and updated. I also updated a step test which was failing due to the changes in dfb7d74. I’m not sure the test is relevant now, can probably be removed altogether :shrug:

patrikholcak avatar Oct 16 '24 08:10 patrikholcak