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

Wrong focus annotation breaks render #377

Open
pomber opened this issue Jun 11, 2023 · 6 comments
Open

Wrong focus annotation breaks render #377

pomber opened this issue Jun 11, 2023 · 6 comments

Comments

@pomber
Copy link
Contributor

pomber commented Jun 11, 2023

```js
mdxOptions = {
  remarkPlugins: [
    // focus(24:44)
    [remarkCodeHike, { theme: "github-light" }],
    anotherPlugin,
  ],
}
```

shows nothing

playground

@knie20
Copy link

knie20 commented Jul 24, 2023

Hi! I'd like to take a stab at this. Hope that works for you.

@pomber
Copy link
Contributor Author

pomber commented Jul 24, 2023

Hi! I'd like to take a stab at this. Hope that works for you.

Sure. I'm planning to refactor how annotations are handled soon, so if it ends up requiring a big change it will be better to wait.

@knie20
Copy link

knie20 commented Jul 25, 2023

gotcha. I'll figure out how big the change is.

@knie20
Copy link

knie20 commented Jul 25, 2023

here's what I found so far.

The render of the code element breaks because the <code> element rendered has its opacity set to 0 due to the data-dh-measured attribute being set to false.
image

I don't fully understand why this is happening yet, but I have found that with a faulty focus annotation,

// focus(24:44)

the render loops (as in hitting the below breakpoint) through code-tween.tsx > Wrapper 2 times while a valid focus annotation

// focus(1:2)

loops 6 times. The measured argument passed in changing to true on the 3rd loop.
image

I'll keep investigating. Meanwhile, any feedbacks or directions appreciated

@knie20
Copy link

knie20 commented Jul 30, 2023

more digging around led me to the use-dimensions file. With the faulty annotation, the ref isn't being inserted into the JSX element for React.useRef(null!) to pick up, causing dimensions to return null, on the 2nd render.

Pretty close to a solution I think.

@airtonix
Copy link

no solution?

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