Skip to content
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

Middleware deduping #3012

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

patrikholcak
Copy link
Contributor

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

Copy link

vercel bot commented Oct 11, 2024

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

Copy link

vercel bot commented Oct 11, 2024

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

A member of the Team first needs to authorize it.

@chuckcarpenter
Copy link
Member

@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
Copy link
Member

@patrikholcak docs failed to build due to this error

image

@patrikholcak
Copy link
Contributor Author

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 🤷

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.

2 participants