In React, I noticed that while a padding is added to the page body when the keyboard shows up, the view is never scrolled so that the math-field is visible when the mathVirtualKeyboardPolicy is auto or when it is manual and mathVirtualKeyboard.show({ animate: true }) is called.
It seems that we can forcefully make the view scroll by executing the scrollIntoView command, and that can be done when the keyboard geometry changes, but to make it work, it still seems required to wait for the keyboard animation.
Here is a working example of what is required to make the scroll happen in React, but if you ever change mathVirtualKeyboardPolicy to auto, set mathVirtualKeyboard.show({ animate: false }) or remove the setTimeout, the scroll stops working:
import React, { useState } from 'react';
import 'mathlive';
export default function App() {
const [value, setValue] = useState('');
return (
<>
<div style={{ height: '80vh' }}></div>
<math-field
style={{ width: '100%' }}
ref={(mathfield) => {
if (mathfield === null) return;
mathfield.mathVirtualKeyboardPolicy = 'manual';
window.mathVirtualKeyboard.addEventListener('geometrychange', () => {
setTimeout(() => mathfield.executeCommand('scrollIntoView'), 300);
});
}}
onFocus={() => window.mathVirtualKeyboard.show({ animate: true })}
onBlur={() => window.mathVirtualKeyboard.hide({ animate: true })}
onInput={(evt) => setValue(evt.currentTarget.value)}
>
{value}
</math-field>
</>
);
}
Is this the intended configuration to have auto-scroll when the input is focused, and the keyboard appears?
In React, I noticed that while a padding is added to the page
bodywhen the keyboard shows up, the view is never scrolled so that themath-fieldis visible when themathVirtualKeyboardPolicyisautoor when it ismanualandmathVirtualKeyboard.show({ animate: true })is called.It seems that we can forcefully make the view scroll by executing the
scrollIntoViewcommand, and that can be done when the keyboard geometry changes, but to make it work, it still seems required to wait for the keyboard animation.Here is a working example of what is required to make the scroll happen in React, but if you ever change
mathVirtualKeyboardPolicytoauto, setmathVirtualKeyboard.show({ animate: false })or remove thesetTimeout, the scroll stops working:Is this the intended configuration to have auto-scroll when the input is focused, and the keyboard appears?