question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Extra keyboard animations when changing focus between math fields

See original GitHub issue

Description

Virtual keyboard animates out and back in when changing focus from one math-field to another. We’ve run into this in a few different ways in Brilliant lessons and it’s causing a noticeable amount of disorientation if we have 2 or 3 inputs for a given problem.

Steps to Reproduce

  1. Create a demo page with two math-fields with onFocus as their virtual-keyboard-mode
  2. Focus one of the fields
  3. Focus the other, either by clicking on it or tabbing

Actual Behavior

As you change from one field to the other the keyboard slides out and then back in.

Expected Behavior

The keyboard (assuming the same layout), should stay visually persistent.

Environment

MathLive version master (e259559b)

Operating System macOS 12.3.1

Browser Reproduced on both Safari and Brave

Suggested Fix

Instead of directly fixing the bug, I think what’s really missing here is a virtual-keyboard-mode that allows the caller ultimate control of whether the keyboard is hidden or shown. We have showVirtualKeyboard and hideVirtualKeyboard, however regardless of mode the keyboard will be hidden due to the onBlur in mathfield-private.ts

Instead of always disabling it, allowing it to be left up to the caller would allow them to handle the hiding and showing as relevant to their application.

I’m happy to open a PR to that effect if that sounds reasonable.

Issue Analytics

  • State:closed
  • Created a year ago
  • Reactions:1
  • Comments:15 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
arnogcommented, Jun 30, 2022

OK, I looked into it, but it’s not a trivial change. Any mathfield elements that have been connected to the DOM before makeSharedVirtualKeyboard() has been called have been setup to not use a shared virtual keyboard instance (i.e. they have created their own virtual keyboard instance). If they would expect to be changed after makeSharedVirtualKeyboard() is changed they would have to be unmounted from the DOM, then remounted.

I’ll clarify in the documentation that makeSharedVirtualKeyboard() should be called as early as possible, and before mathfield elements are connected to the DOM.

1reaction
hanshscommented, Jun 13, 2022

While creating an example in a vanilla/no-framework type of setup, I managed to reproduce the faulty behaviour I described previously, heres the example repo - https://github.com/hanshs/mathlive-vite-vanilla-ts In /src/main.ts there are instructions on how to toggle between the faulty and correct behaviour.

Looks like calling setOptions for a math-field instance, causes the behaviour to break.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Virtual Keyboards - CortexJS
A virtual keyboard is a keyboard displayed on screen that can be customized with specialized symbols for math input.
Read more >
Create advanced animations with smart animate
In the Animation section, select Smart animate from the transition field. Apply Easing to the transition, or change the Duration (optional). Repeat for...
Read more >
focus - CSS: Cascading Style Sheets - MDN Web Docs - Mozilla
It is generally triggered when the user clicks or taps on an element or selects it with the keyboard's Tab key. Try it....
Read more >
Animation transitions - Unity - Manual
To give transitions a name, type it into the field as shown below: ... Change the transition properties in the graph view using...
Read more >
Move textfield when keyboard appears swift - ios
Firstly the UIKeyboardWillChangeFrameNotification is probably the best notification as it handles changes that aren't just show/hide but changes due to keyboard ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found