Exclude hidden posts from page search #1544
Open
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
When a post is hidden by any of our post hiding features, searching the page for a term that is in that post will result in hits if and only if the post in question is far off the screen, due to the way tumblr's virtual scroller component works.
This adjusts the CSS that we use to create hidden posts so that post elements will have both their element children and text node children removed from the DOM, preventing them from being searched. It uses the css
content
property to replace post element contents (whatever they are) with a no-op "image", which is supported as of Firefox 113. We cannot simplydisplay: none
the target post elements themselves, as we need them to continue to be rendered and have bounding boxes so that j/k scrolling code continues to find them.Notably, this also does the same thing as #593, i.e. presumably making Tumblr's observer elements (correctly) think the user is not viewing the post in question. As mentioned in that PR, I don't know if there are actual consequences of this.
(Height is set to 0 because apparently in Chromium unset-height gradients are half as tall as they are wide. No idea why this is; a linear gradient should have no intrinsic height. This isn't necessary in Firefox. But sure, I guess, why not.)
Resolves #1543.
Testing steps
Tested in Firefox 121.
Show Originals smoke tested in Chrome 126 and desktop Safari 17.4.1