Skip to content
This repository was archived by the owner on May 17, 2024. It is now read-only.
This repository was archived by the owner on May 17, 2024. It is now read-only.

Left Position of Element Not Set Until Scroll in Next.js App #782

@Battjmo

Description

@Battjmo

Weird little issue: I've made a very basic two-step tutorial to test out the library for my app.

I've set my two steps to attach to a search bar in the middle of the page, the first on bottom, the second top

Options and steps:

  const tourOptions = {
    defaultStepOptions: {
      cancelIcon: {
        enabled: true,
      },
    },
    useModalOverlay: true,
  };

  const tourSteps: any = [
    {
      id: "welcome",
      text: "Welcome to ...! This is a quick tour of the features you can expect to find here.",
      attachTo: {
        element: "#searchBar",
        on: "bottom",
      },
      buttons: [
        {
          classes: "shepherd-button-secondary",
          text: "Exit",
          type: "cancel",
        },
        {
          classes: "shepherd-button-primary",
          text: "Back",
          type: "back",
        },
        {
          classes: "shepherd-button-primary",
          text: "Next",
          type: "next",
        },
      ],
      classes:
        "flex flex-col z-40 bg-white text-black border-black border-2 border-dashed p-3 ",
    },
    {
      id: "secondi",
      text: "Welcome to ...! This is a quick tour of the features you can expect to find here.",
      attachTo: {
        element: ".search-bar",
        on: "top",
      },
      classes:
        "flex flex-col z-40 bg-white text-black border-black border-2 border-dashed p-3 ",
    },
  ];

When I click the button to start the tutorial, or the next button to bring up the second step of the tutorial, the popups are always left-aligned, then snap into the correct position on scroll. The left style on .shepherd-element only gets populated on scroll, seems to be the issue. The top is correct.

I'm using Next.js, but this is a client component so it shouldn't be a serverside rendering issue or anything I would think. I tried hooked it up to window to make sure and that didn't help.

Totally possible I've missed something silly here, would appreciate any help, thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions