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 size seems to be competing with floating ui offset #2949

Open
jkochocki opened this issue Aug 13, 2024 · 3 comments
Open

Arrow size seems to be competing with floating ui offset #2949

jkochocki opened this issue Aug 13, 2024 · 3 comments
Labels

Comments

@jkochocki
Copy link

jkochocki commented Aug 13, 2024

Hi, I'm trying to use an offset to place the floating element diagonally adjacent to a target with a smaller height (I believe this is important to note).
example:
image

I believe I'm using the floating ui api correctly (at least, according to their docs) in how I'm setting the offset:

      middleware: [
        offset(({ rects }) => {
          console.log(rects);
          return {
            alignmentAxis: -rects.floating.height,
          };
        }),
      ],
    },

However, I am trying to use a custom arrow icon. I am finding that setting a height larger than 16px (the initial shepherd styling for the arrow) causes the floating element's position to jump, such that it is no longer aligned how I would like. This is for a right-end-positioned step.

example (17px height arrow)
image

I'm wondering if this is a bug in how shepherd is using floating ui or if it's improper usage on my part. If it's something on my end, could I please get some guidance for how to achieve what I want?

sandbox

In playing around with it, it seems to be some function of the target height vs. the arrow size that causes the floating element to jump. e.g. a 17px arrow on a 24px target will not be positioned correctly, but will be positioned correctly on a 25px target. I don't see why this is, as I would expect the positioning of the floating element to be independent of the size or position of the arrow.

@chuckcarpenter
Copy link
Member

Offhand, I'm not sure, but we do a little bit here https://github.com/shepherd-pro/shepherd/blob/main/shepherd.js/src/utils/floating-ui.ts and wondering if there's an issue in that? Strange that a 1px difference would cause that. I'll try to take a look as well this week.

@2021eo3ar
Copy link

@chuckcarpenter, could you please label this issue as hacktoberfest, and assign to me as well, I can come up with a better solution.

@chuckcarpenter
Copy link
Member

@2021eo3ar sorry I really dropped the ball on that one, happy to take a PR if you're doing any Xmas hacking!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants