improvement: always find a preview to render #2035
Merged
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.
An unanticipated side effect of using the new
search_data
for customizing what appears in autocomplete and search is that, unless your search result points at a header (the entire thing we need to avoid), the preview option will show no content.CleanShot.2025-01-18.at.10.58.56.mp4
I've added a change that I'm hoping will be amenable that improves this. At worst case, it will help in the case of some unexpected structure of the page in normal usage. It only kicks in after the current preview finding logic, which goes to the header in question and grabs the following content.
What this does, is goes up until it finds a header, and uses that, or falls back to the top content. To me this seems like a reasonable solution because the preview is still always a header in the document, not something customizable in
search_data
for example. I will likely need to do additional reworking of the way that our DSL docs so that the first parent header is a sensible thing to preview for any given DSL option.CleanShot.2025-01-18.at.10.57.10.mp4
If we can't do this or something like it, then we should revert the entire custom search data feature, because this points out that the only place safe to include in autocomplete into an extra is a header. I really really really hope we don't have to do that though 🙏