Skip to content

add askIfShouldIgnoreMousedown()#343

Merged
mikehaverstock merged 3 commits intomainfrom
mike/add-ignore-mouse-move
Feb 27, 2026
Merged

add askIfShouldIgnoreMousedown()#343
mikehaverstock merged 3 commits intomainfrom
mike/add-ignore-mouse-move

Conversation

@mikehaverstock
Copy link
Copy Markdown
Member

The idea is that sometimes mathquill is embedded in bigger documents. You can start a selection within the mathquill but eventually your mouse can move outside of the mathquill and onto other text that should get selected. When selection is handled by something higher up you want mathquill to stop responding to mousemoves. Otherwise you get fighting between the parent that's trying to select the entire mq. You can't just cancel the mousemove listeners because your mouse might move back into the mathquill. At that point you want the mq to resume taking control of the selection.

This also fixes a bug where if a mathquill loses focus and gains it again during a mouse selection it'll restore the selection to where it originally started instead of being cleared to the end.

Comment thread src/publicapi.ts
constructor(public version: 1 | 2 | 3) {}

ignoreNextMousedown: (_el: MouseEvent) => boolean;
askIfShouldIgnoreMousemove: (
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Naming: should this just be ignoreMousemove? That would be consistent with the existing ignoreNextMousedown

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Maybe. That one is weird becuase we dont use the callback. We use the method that you can call. So the callback version doesnt really need to exist. And this definitely isn't something you should call to ignore a mousedown. It really is only there to answer the question when mathquill needs it answered

@mikehaverstock mikehaverstock merged commit b0de8a4 into main Feb 27, 2026
3 checks passed
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.

2 participants