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

Arrow position not working when using custom FloatingUI options #3034

Open
lalpou opened this issue Oct 21, 2024 · 3 comments
Open

Arrow position not working when using custom FloatingUI options #3034

lalpou opened this issue Oct 21, 2024 · 3 comments

Comments

@lalpou
Copy link

lalpou commented Oct 21, 2024

I'm using the following custom FloatingUI options in the "defaultStepOptions":

const shepherdTour = new Shepherd.Tour({
    steps: tourOptions.steps,
    keyboardNavigation: true,
    defaultStepOptions: {
	    scrollTo: { behavior: 'smooth', block: 'center' },
	    floatingUIOptions: {
		    middleware: [shift({ padding: 32 }), offset(16)]
	    }
    }
});

When the position of the tooltip is calculated, the middleware of the arrow and the shift options is applied in the following order:

[flip, shift, arrow, shift, offset] // The first 3 are from internal Shepherd.js settings

This causes an issue with how the arrow is placed, since the arrow middleware should be last in the order.

I've attempted to fix this using the beforeShowPromise and the whenShow functions, but run into issues with applying the arrow middleware in those places. In the beforeShowPromise the step element hasn't been generated yet, meaning the arrow can't be targeted and in the whenShow function the computePosition function for FloatingUI has already been run.

How can I apply shift with padding while still achieving correct arrow placement?

@lalpou
Copy link
Author

lalpou commented Oct 22, 2024

Reverting back to before the changes made in #3005 fixes the problem. I guess some of the default middleware should still override the user set ones (such as the arrow)

@RobbieTheWagner
Copy link
Member

Thanks for letting us know @lalpou. @chuckcarpenter I wonder if we need to not just merge the options but like merge some and push some onto the end etc?

@chuckcarpenter
Copy link
Member

@RobbieTheWagner I think it's worth testing an append of arrow last, unless there's a user supplied one

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

No branches or pull requests

3 participants