Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tt button not working in some web browsers (with develop branch) #1175

Open
Alex-Jordan opened this issue Jan 10, 2025 · 7 comments
Open

Tt button not working in some web browsers (with develop branch) #1175

Alex-Jordan opened this issue Jan 10, 2025 · 7 comments

Comments

@Alex-Jordan
Copy link
Contributor

On develop (but not in 2.19), when I am using Chrome (but not when I am using Firefox), using the Tt button in the math entry toolbar for MathQuill does not work. If I click it, there is a momentary flash of something in the input field.

@drgrice1
Copy link
Member

Hmm... I will take a look at it. This is one of the downsides of me using Firefox in development so frequently I guess. It is odd though that it would have an issue in Chrome and not Firefox. It is even odder that there is no console error or anything.

@somiaj
Copy link
Contributor

somiaj commented Jan 10, 2025

I can verify it isn't working either. Further I see that if I have text in the input, the first time I hit the button it selects all the text, and the second time with all the text selected it erases the selected text.

@drgrice1
Copy link
Member

I have been fighting with this for hours now, but the issue is clearly a bug in Google Chrome. According to the specification (see https://w3c.github.io/uievents/#event-type-focusout) the relatedTarget should be set for a focusout event. However, Google Chrome isn't doing that. As a result the focusout event handler on line 345 of mqeditor.js does the wrong thing and deletes the toolbar when it shouldn't. I can't find a work around.

Google Chrome is moving up on the list of browsers that are annoying. The other issue is their stupid third party cookie handling. I have found no way at all to get the LTI content item selection to work in Google Chrome with their new rules on that. In fact, Google Chrome is now worse than Safari with these two issues.

@Alex-Jordan
Copy link
Contributor Author

Well, thanks for trying. We probably just have to wait for the bug to be resolved.

I wanted to report that it also happens with Edge. Is that based on the same code base as Chrome? I have a PCC Windows laptop now that I can use for testing Windows-y things now, like Edge. Altough, I do not have admin access to it, so there's a limit to what I can test.

@Alex-Jordan
Copy link
Contributor Author

Might as well mention that in addition to Firefox, the issue is not an issue in Safari.

@drgrice1
Copy link
Member

Yes, Edge is based on the same chromium engine.

I am still working on this, and hopefully will find something that works.

drgrice1 added a commit to drgrice1/pg that referenced this issue Jan 10, 2025
When a text block is entered all of the buttons on the toolbar are
disabled.  So when a user clicks on the text button, focus moves from
the MathQuill input to the text button, and then the text block is
created.  At this point the text block is entered and the buttons
disabled.  Then focus is sent back to the MathQuill input.  However, for
some reasone with the button disabled, Google Chrome decides not to set
the relatedTarget to the MathQuill textarea in the focusout event on the
toolbar. Then the mqeditor focusout handler doesn't know that focus is
going back to the MathQuill textarea and removes the toolbar.  Then
things go haywire, and that triggers the removal of the text block that
was just created as well. Other browsers (Firefox and apparently Safari)
still set the relatedTarget correctly in this case.

This implements a bit of a hack and sets a preventRemove flag on the
toolbar when the buttons are disabled, and when the focusout handler
occurs it sees the flag and doesn't remove the toolbar.

This fixes issue openwebwork#1175.

Also remove an erroneous console.log that was left in a previous commit.

I also noticed another bug with text blocks while working on this.  When
focus is lost from the MathQuill input entirely and the cursor is inside
an empty text block, then the text block is not removed as it should be.
Furthermore, if the text block is clicked on after that an exception is
thrown.  This ensures the text block is removed in this case so that
when focus returns the exception is not thrown. That bug is fixed in
openwebwork/mathquill#35, and the dependency
updated here.
@drgrice1
Copy link
Member

I found a work around!

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

No branches or pull requests

3 participants