spectacle icon indicating copy to clipboard operation
spectacle copied to clipboard

Code highlighting not working when returning to previous slide

Open JiDai opened this issue 5 years ago • 3 comments

Prerequisites

Feel free to delete this section if you have checked off all of the following.

  • [x] I've searched open issues to make sure I'm not opening a duplicate issue
  • [x] I have read through the docs before asking a question
  • [x] I am using the latest version of Spectacle

Describe Your Environment

What version of Spectacle are you using? [email protected]

What version of React are you using? [email protected]

What browser are you using? Firefox/Chrome

What machine are you on? OSX

Describe the Problem

When I back to the previous slide the code block does not scroll to the right line but stay at top of the frame. On my example It works once but after second back, the problem appears. On my project it happens at first back. It seems happens with long code when highlighting a bottom line.

https://codesandbox.io/s/spectacle-code-scroll-problem-m9yi5

Expected behavior: [What you expect to happen] Code block scrolls at the right code line

Actual behavior: [What actually happens] Code block scrolls to the top

JiDai avatar Jun 07 '20 08:06 JiDai

I use the Stepper component as a workaround.

<Stepper values={[[56, 65], [58, 58], [64, 64]]} defaultValue={[]}>
      <CodePane
        language="js"
        autoFillHeight
        highlightStart={value[0]}
        highlightEnd={value[1]}
      >
          {longCode}
      </CodePane>
</Stepper>

Besides, the defaultValues prop is mandatory to prevent an error value is undefined

JiDai avatar Jun 07 '20 09:06 JiDai

Can verify this bug, but it does appear to function as expected if you navigate backwards slowly. If I wait 2 seconds before hitting navigating to the previous slide, it jumps to the correct line, even without use of Stepper. 🤔 Still, not ideal behavior - going to look into this further.

kale-stew avatar Jun 18 '20 14:06 kale-stew

I verified this issue has been fixed in upcoming v7! 🥳 🎉

1198-fix

christianipanaque avatar Nov 12 '20 00:11 christianipanaque

Confirmed as fixed. Demo here: https://codesandbox.io/s/spectacle-code-scroll-problem-forked-ldms7y?file=/src/index.js

fritz-c avatar Sep 20 '22 18:09 fritz-c