-
-
Notifications
You must be signed in to change notification settings - Fork 12
onChange callback doesn't trigger #6
Comments
Current workaround is to use |
What about 1.3.2? Sounds like something from Mathlive |
Doesn't work with 1.3.2 as seen from the repro sandbox |
Hey @ShaMan123! I'm facing the same issue. I tried toggling onChange even from inside |
After digging into the code, it's as if the |
Thanks for this. Line 78 in f20b80c
It might be overriding the the previous line. |
Another relevant check would be to test if |
Could you mention this issue on the ticket in mathlive? |
So far, I have tried changing And thanks for the suggestion, I will create a new repo and tests things out on mathlive itself just to see what happens. Also, I will mention this ticket in mathlive. Thanks for your support @ShaMan123! |
Great. If a PR is needed I will back you, so ask what you need. |
And a disclosure: there's another repo that abstracts mathlive to react. |
Thank you @ShaMan123! So I've done a bit of testing on mathlive itself directly on html and css. I used the same copy of I've added the following code in my html file and input worked flawlessly! It was triggered on every keystroke as expected. <math-field id="math" virtual-keyboard-mode=manual>
x=\frac{-b\pm\sqrt{b^2-4ac}}{2a}
</math-field>
<script>
math.addEventListener('input', (ev) => {
console.log(ev.target.value);
});
</script> Then I went and added the following code in this file by referencing useEffect(() => {
console.log(_ref);
_ref.current?.addEventListener("input", () => {
console.log("input");
});
return () => {
_ref.current?.removeEventListener("input", () => {});
};
}, []); To my surprise, the above code didn't work! Theoretically it should, but what I noticed is the fact the console logs input once when the page is first loaded! |
I tried working with |
This is strange.
Can you attach 2 event listeners to |
Another thing I want to check is how many time this function is called. Line 194 in 6d073df
|
Good, I suppose that's why it's commented out. |
Alright another check. |
Both fired once right when the page loaded.
Tested it. It only fires once.
No it isn't. I haven't touched useCallback since I was trying simply to get the event to trigger. Can you write a quick code with your suggestions if you have the time? |
Can you share some fiddle/codesandbox?
Can you do that on the mathlive pure prepo? |
https://codesandbox.io/s/stupefied-https-7kr01?file=/src/App.tsx
I've done that to the pure repo and it worked. |
this looks like a major commit daf92fb I would start with |
Or try to revert it altogether |
Thanks, this was a good pointer! So far, this means that I can access the value by calling I'm looking into the code and will create a PR if I can fix this. Your input would be much appreciated. |
try safeguarding Line 163 in daf92fb
- ...props,
+ ...(props || {}), |
try removing Line 12 in daf92fb
|
and test this as well Line 22 in daf92fb
Does it fire? |
I don't see how this will work, syntax-wise, inside a function.
Nope, nothing happened here.
Since |
@ShaMan123 @tech-chieftain any updates on this? I can't get it to work as well |
As I mentioned I don't have enough time to dedicate to this project. |
@ShaMan123, onInput and onChange are still not called. I changed this souce code line
Your library makes a huge contribution. |
@coprocoder What about updating mathlive? do you try it? Did you look for issues there regarding this problem? |
Describe the bug
onChange callback doesn't trigger
To Reproduce
Steps to reproduce the behavior:
Expected behavior
Console should print the event
Additional context
It seems to work with last version 1.3.1
The text was updated successfully, but these errors were encountered: