chore: pass highlightedRefsInSheet from SheetsWithRefPage #2246
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
We have a feature in production that was not implemented when we created the Sheets With Ref Page this summer. The feature is that if a user has "Exodus 7:1" open in the reader and opens a sheet from the sidebar, the sheet will scroll to highlight the source "Exodus 7:1" in the sheet. In modularization, when a user tries to open a sheet from the reader, they are taken to a new page, the Sheets With Ref Page which displays all the sheets for the given ref with appropriate topic filters (like the Search Page). However, previously in the modularization branch, when a user would click one of these sheets, the sheet would not scroll to "Exodus 7:1" and highlight it. This PR corrects this.
Code Changes
There's a function in ReaderPanel, handleSheetClick, which is used in production to implement this feature. I used the same function, by passing it to the SheetsWithRefPage component, which ultimately passes it all the way to SearchSheetResult. I had to slightly modify handleSheetClick in ReaderPanel and slightly modify the click handler in SearchSheetResult, which is confusingly also called handleSheetClick. The substantive difference in the SearchSheetResult click handler is that I need to check if the query passed is a search query (i.e. plain text) in which case we should use the this.props.onResultClick handler that was already being used before, OR if the query passed is in the form of a valid Sefaria ref, in which case we know that the function passed down as this.props.onResultClick is really the ReaderPanel's handleSheetClick.