react-mathquill icon indicating copy to clipboard operation
react-mathquill copied to clipboard

Cannot update mathquill configuration after mount

Open iamdiogo opened this issue 4 years ago • 3 comments

I noticed that EditableMathField persists the initial mathquill configuration passed on mount.

There are cases where updating the internal configuration could be required. An example of this is when we're defining custom handlers for the editor.

By persisting the initial configuration, if those handlers require access to state variables, those handlers would be using old versions of those handlers, with the old value of those state variables.

To illustrate this, I made a simple example: https://codesandbox.io/s/react-mathquill-old-config-persistent-8stef

Note: I understand that it is still possible to manually set the configuration by accessing the mathquill object directly, but this new addition could be great for react-mathquill.


Regarding the implementation of it, I noticed mathquill has a method .config(config) that could be used for updating the configuration. This method could be used on a per-field basis, so there is no need to re-combine the custom edit handler required by react-mathquill.

iamdiogo avatar Nov 09 '20 19:11 iamdiogo

Hi @iamdiogo, thank you for the detailed issue.

I didn't know that mathquill had the .config(config) method. I think this would be a great addition. Do you want to take a shot on implementing this?

viktorstrate avatar Nov 09 '20 20:11 viktorstrate

Hi @iamdiogo, thank you for the detailed issue.

I didn't know that mathquill had the .config(config) method. I think this would be a great addition. Do you want to take a shot on implementing this?

Yeah, I'll give it a go later this week

iamdiogo avatar Nov 09 '20 21:11 iamdiogo

I experienced the same issue but with the onMoveOut handler. I also noticed the issue with the onChange callback with the new version. You an check here: https://codesandbox.io/s/jovial-sea-wvmfq

Notice that when you change the react-mathquill version to 0.28, it works as expected.

alx-ppv avatar Jan 28 '21 07:01 alx-ppv