Text when editing formulas displays cursor in wrong position

I’ve been using Grist for a few weeks now, but this issue is making me consider going back to other alternatives. When editing formulas, the text cursor offsets itself way more than the characters on the screen. This happens more as I add references to other cells.
See the following screenshot:
20230827T170005
In this image, the text cursor should be at the end of the text, but it’s instead way ahead of the text. If I press backspace, for example, the last character is correctly removed, but the offset still remains (I can’t add another image to the post due to being a new user, but just imagine the last picture without the last “0” and with the text cursor slightly to the left).

This doesn’t seem to happen when just using simple formulas like =123*456. It starts to happen as I reference other cells in the formula. This happens both on Firefox and Chromium.

Right now the only workaround I have is to copy the formula text to a text editor, edit things there, then copy them back into Grist, because trying to do everything inside Grist is just a horribly frustrating exercise.

Sorry you are seeing this problem! We haven’t seen it in the environments we’ve been testing (and using) Grist on. Which OS are you on? Do you know if you have any extensions or special font versions installed?

Thanks for the reply! Grist is still a super cool project, and I appreciate all the work you folks put into it!
I’m on Linux (using Arch Linux, kernel 6.3.9-arch1-1). No extensions which should be messing with fonts, but due to how Arch lets users manage fonts, I only have two font packages that should be preferred in the entire system, and a few extra fonts installed by other software.
I had set up the fonts on my system a long time ago and never looked at it again, but your question made me go back and re-read the documentation and understand better what was going on.

My config was force-prepending a sans-serif font family to the list of fonts to consider in every possible case. You can see from the screenshot in the original post that the font being used is clearly not monospace (which is what Grist requests from the browser). After removing that part of the config, Firefox is now displaying a monospace font, and the formula editor is working properly now.
The screenshot below shows the fix (with a few other changes, like updating the sans-serif font I was using and switching to the dark theme in Grist):
20230827T202558

This is curious because I haven’t had this problem in every other application I’ve used (code editors and terminals were properly using monospace fonts, for example). Even Firefox was using monospace fonts when requested by every other site I visited (code snippets in documentation sites were also using monospace fonts, for example).
I peeked at the HTML produced by Grist, and the way it positions the text cursor is not straightforward. Looks like somewhere in the code, the editor was calculating the position of the cursor (in pixels) as if it was displaying a monospace font, but the browser was showing me the text with a different font.

In any case, this is now fixed for me, although it seems like there’s still a tricky bug in Grist’s editor code which you folks might want to file even if just for awareness.

For anyone that happens to find this post in the future, my font config file in ~/.config/fontconfig/fonts.conf had the following config that I completely removed to fix this problem:

  <match>
    <edit mode="prepend" name="family">
      <string>NotoSans Nerd Font</string>
    </edit>
  </match>

I’ve also had this issue occur seemingly randomly, but can’t remember where exactly. I’ll keep an eye out for the next time it happens.

I, too, periodically encounter this problem, I restart the container and reset the browser cache.