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

highlight not updated when the property is changed #43

Open
yonghah opened this issue Sep 5, 2024 · 5 comments
Open

highlight not updated when the property is changed #43

yonghah opened this issue Sep 5, 2024 · 5 comments
Assignees
Labels
bug Something isn't working

Comments

@yonghah
Copy link

yonghah commented Sep 5, 2024

Hi,
It seems that changing highlight property doesn't update the component.
I have a react code like below to scroll AND highlight to the specific line.

const [lineNumber, setLineNumber] = useState(1);
<LazyLog
  text={mlirData?.content}
  scrollToLine={lineNumber}
  highlight={lineNumber}
/>

When the lineNumber is updated, LazyLog is scrolled to the line number as expected. But the highlight is not updated.
Do you have any idea?

@melloware melloware added the bug Something isn't working label Sep 7, 2024
@melloware
Copy link
Owner

I think your issue is similar to this one: #37

It seems wiht React Virtual Window is scrolling to the end of the first virtual frame or something.

@melloware melloware added this to the 5.2.1 milestone Sep 7, 2024
@melloware
Copy link
Owner

I just released 5.2.1 can you try it and report back i think its fixed.

@melloware melloware self-assigned this Sep 7, 2024
@yonghah
Copy link
Author

yonghah commented Sep 9, 2024

Hi melloware! Thanks for your attention.
I updated to the 5.2.1 release, but highlight is still not working.
It seems that highlight state is not updated. If I add onHighlight, then onHighlight function is triggered when I change the lineNumber, but the value printed from console.log(line) is always the initial value, not mutated at all.

const [lineNumber, setLineNumber] = useState(1);
<LazyLog
  text={mlirData?.content}
  scrollToLine={lineNumber}
  highlight={lineNumber}
  onHighlight={(line)=>console.log(line)}
/>

@melloware melloware reopened this Sep 9, 2024
@melloware
Copy link
Owner

@melloware
Copy link
Owner

I see why.

highlight:
                previousHighlight === Range(0, 0)
                    ? getHighlightRange(highlight)
                    : previousHighlight || getHighlightRange(previousHighlight),

The old code intentionally only set the Highlight on initialization but after that it was controlled by your mouse clicks. I wonder if this is so highlighting would not be lost between re-renders?

@melloware melloware modified the milestones: 5.2.1, 5.2.2 Sep 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants