Skip to content

Add scroll marker using fake scrollbar implementation - #436

Open
arogl wants to merge 36 commits into
brandon1024:developfrom
arogl:scollbar-highlight
Open

Add scroll marker using fake scrollbar implementation#436
arogl wants to merge 36 commits into
brandon1024:developfrom
arogl:scollbar-highlight

Conversation

@arogl

@arogl arogl commented Mar 28, 2026

Copy link
Copy Markdown

Fixes

#368

Changes Proposed in this Pull Request:

  • Add scollbar marker to options
  • Show markers on scrollbar

Additional Comments and Documentation:

Produced with the help of claude

@pzhlkj6612

Copy link
Copy Markdown
Contributor

interesting! do you have screenshots?

@arogl

arogl commented Mar 28, 2026

Copy link
Copy Markdown
Author

Options screen
image

No Matches
image

Matches on news.com.au

image

It has light and dark scrollbar capability, but not extensively tested

follow existing style.
- Can put "enable" or "disable" in description instead of messages.
- Can omit "_enabled" from js code to shorten code lines.

@pzhlkj6612 pzhlkj6612 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code and L10N strings in this PR don't seem to be consistent with the existing style and design, and there are some useless if-else and try-catch statements.

I've modified your changes in arogl#1. PLease check. The code in "content/highlighter.js" needs more cleanup and I'm working on it.

You can directly merge that PR if it looks good to you. The merge commit can be preserved, and you don't need to force-push. The maintainer will squash all commits during PR merging.

I believe that keeping things consistent will help future developers. I also believe that we will compose some linter rules for this project then.

@pzhlkj6612

Copy link
Copy Markdown
Contributor

Thank you for merging the code.

Now I'm continuing working on it. I think all markers in the virtual scrollbar should be added and removed simultaneously with the addition or removal of occurrences on the page, then the procedure will look more tidy and more integrated.

@brandon1024

Copy link
Copy Markdown
Owner

Let me know when these changes are ready and I’ll have a final review 👍

@arogl

arogl commented May 1, 2026

Copy link
Copy Markdown
Author

Sorry forgot about this one.

@pzhlkj6612

Copy link
Copy Markdown
Contributor

Thanks. I'm working on removing all try-catch blocks these days. The code in this PR looks to be against the existing code style.

@pzhlkj6612 pzhlkj6612 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. I'm working on removing all try-catch blocks these days. The code in this PR looks to be against the existing code style.

I'm back and finished a mass PR. Please see arogl#2. Commit messages in it are also important.

Cleanup, reorganization, encapsulation.
@arogl

arogl commented Aug 6, 2026

Copy link
Copy Markdown
Author

Thanks. I'm working on removing all try-catch blocks these days. The code in this PR looks to be against the existing code style.

I'm back and finished a mass PR. Please see arogl#2. Commit messages in it are also important.

I merged in and tested locally, it worked

@brandon1024

Copy link
Copy Markdown
Owner

Let me know when this is ready for final review 👍

@pzhlkj6612 pzhlkj6612 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let me know when this is ready for final review 👍

Looks ready for final review! Let's move on and have this feature in the upcoming new version.

Comment thread content/highlighter.js
Comment thread content/highlighter.js Outdated
Comment thread content/highlighter.js Outdated
Comment thread content/highlighter.js Outdated
Comment thread content/highlighter.js
for (let currIndex = 0; currIndex < len; currIndex++) {
charMap[charIndexMap[offset + currIndex]].ignorable = true;
}

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you revert these whitespace changes? I don't like seeing code all bunched up like this, too difficult to follow.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you revert these whitespace changes? I don't like seeing code all bunched up like this, too difficult to follow.

Addressed by arogl#3.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe @arogl is not familiar with or forget to read git-diff. It's very clear that we have some unneeded changes there: 2f047ec~1...bb8795a .

@brandon1024

Copy link
Copy Markdown
Owner

Changes look good to me, aside from the whitespace comment. I'll do a few tests locally, but should be able to merge soon.

@brandon1024

Copy link
Copy Markdown
Owner

LGTM. Once the whitespace fixes are done, can you squash your changes? I'll merge once done.

@pzhlkj6612

Copy link
Copy Markdown
Contributor

I'm cleaning unimportant changes in files such as manifest_firefox.json.

JS:

- We don't need to move the "charMap.length = count" line.
- We don't need to remove those empty lines and affect readability a little bit?

JSON:

- Really, copy-paste is quick, but git-diff is a bit hard to read.
- The EOF empty line is a pain for GitHub since the Web UI editor will always add that line. We should keep it.

@pzhlkj6612 pzhlkj6612 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We're almost there!

In my view, there are still some minor flaws in this code. The comments below are for good changes, while my suggestions are in the PR: arogl#3

Comment thread content/highlighter.js Outdated
}
}

// Collect occurrence IDs from highlight spans

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice clean. that was a leftover.

Comment thread content/highlighter.js Outdated
Comment on lines +280 to +272
if (options && options.scroll_markers) {
scrollbarMaker.setActive(index);
if (options.scroll_markers) {
Find.Content.ScrollbarHighlightMaker.setActive(index);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice removal of the undefined check with options since we have already checked it above.

@pzhlkj6612

Copy link
Copy Markdown
Contributor

@brandon1024

LGTM. Once the whitespace fixes are done, can you squash your changes? I'll merge once done.

Maybe we can keep the history in this PR? When merging PR, you're able to choose "squash and merge", and then all of our reviews and comments are still meaningful and the "develop" branch should have only one commit. Force-pushing is not recommended, at least in my opinion.

Docs: Merging a pull request - GitHub Docs | https://docs.github.com/en/pull-requests/how-tos/merge-and-close-pull-requests/merging-a-pull-request#merging-a-pull-request .

Restore unneeded changes from JS and JSON files

@pzhlkj6612 pzhlkj6612 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we're almost there.

Comment thread content/scrollbar.js
Comment on lines +215 to +226
/**
* Initialize the component with the given search options, discarding
* any previously mounted overlay. Must be called before mount().
*
* @private
* @param {object} newOptions - The search and highlight options
* */
self.init = function (newOptions) {
self.destroy();
options = newOptions;
occTopPositionMap = new Map();
};

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/**
* Initialize the component with the given search options, discarding
* any previously mounted overlay. Must be called before mount().
*
* @private
* @param {object} newOptions - The search and highlight options
* */
self.init = function (newOptions) {
self.destroy();
options = newOptions;
occTopPositionMap = new Map();
};
/**
* Initialize the component with the given search options, Must be
* called before mount().
*
* @private
* @param {object} newOptions - The search and highlight options
* */
self.init = function (newOptions) {
options = newOptions;
occTopPositionMap = new Map();
};

We already have a Find.Content.ScrollbarHighlightMaker.destroy() call in "self.restore()" of "content/highlighter.js", so any leftover will be cleaned up. So, we can safely remove it from here.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, we can safely remove it from here.

So, we can safely remove the self.destroy() call from here.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comments should be updated, too.

I don't know if the suggested changes above are readable on your web browser? GitHub's UI is glitch sometime, so you may need to refresh it multiple times.

Comment thread content/scrollbar.js
Comment on lines +297 to +302
if (overlay && overlay.parentNode) {
overlay.parentNode.removeChild(overlay);
}
if (globalStyle && globalStyle.parentNode) {
globalStyle.parentNode.removeChild(globalStyle);
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we can apply lint rules in the future for using the convenient "Optional chaining" stuff? I dunno. I prefer optional chaining. Now let's don't change it and keep the style consistent with other code lines. Here I'm just making notes.

Comment thread content/scrollbar.css
Comment on lines +58 to +64
#find-ext-scroll-marker-container {
position: absolute;
top: 0;
left: 0;
right: 0;
height: 100%;
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mouse can't drag and drop the thumb, unless we do this:

Suggested change
#find-ext-scroll-marker-container {
position: absolute;
top: 0;
left: 0;
right: 0;
height: 100%;
}
#find-ext-scroll-marker-container {
position: absolute;
top: 0;
left: 0;
right: 0;
height: 100%;
pointer-events: none;
}

(Then the same declaration for each marker in .find-ext-scroll-marker {...} can be removed.)

Embarrassingly, my previous implementation didn't care about the style of the marker container, and then the mouse could normally interact with the thumb. Bug was hidden.

HOWEVER, since we don't have any overflow related things applied to the container, a zero-pixel-width and zero-pixel-height DIV does not hurt anything. Directly remove this rule from here and the corresponding class naming thing from "scrollbar.js" looks simpler and more acceptable to me.

Suggested change
#find-ext-scroll-marker-container {
position: absolute;
top: 0;
left: 0;
right: 0;
height: 100%;
}

What do you thing?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

06be275: directly removing the marker container is not a bad idea but looks like my intent about using that container didn't express clearly. Let me explain more:

  • No track.querySelectorAll(...), but a simple markerContainer.children. The code will be more understandable to future developers including all of us a month from now.
  • Managing common properties is simple. For example, the pointer-events: none; declaration.
  • Better dev experience: in Developer Tools, we can collapse all makers into one parent element and see a clear view, like this:
    screenshot of selected elements created by the Find extension in Firefox' Developer Tools
    Thus, if you're going to inspect something other than markers, for example the thumb, then those markers won't bother you.

That's it. I really recommend you use a container.

arogl added a commit to arogl/find that referenced this pull request Aug 14, 2026

@pzhlkj6612 pzhlkj6612 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It works. Now let's wait for @brandon1024 to test this PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants