Closed etrokal closed 1 month ago
Adding to my proposed solution, we should probably reload the typeahead instance before removing fields as well. I don't know the details about typeahead internals, but we could be introducing a memory leak if we remove the field first.
Thanks for the report!
@etrokal and for the analysis.
I have implemented a fix that does not work, and I can't see why. Pushed as #2237, I'm open to any ideas..
Some hledger-web dev workflow notes for the record:
just ghci-web
to load hledger-web into GHCI and :main --port 5001 -f examples/sample.journal
to start it.And here's one comment suggesting just calling .typeahead() on the new element should be enough.
Fixed in master by the latest #2237.
How to reproduce:
Ledger version
hledger 1.34-g7a83578ec-20240601, windows-x86_64
How severe is this bug ?
severity2
Who is likely to be impacted by this bug ?
Since it appeared to fly under the radar for sometime, I believe only a small portion of the user base would be impacted. Most people would be satisfied with the first 4 account fields. So impact3.
Proposed solution
I'm not a Haskell developer, nor do I know which web framework is being used, but the issue seems to be on the javascript side. When adding the new field, we should be destroying the typeahead instance and reloading it to include the new field. Since we are not doing this, the current typeahead instance doesn't know about the new field.
Looking at the source code, I reckon these 2 files should be affected:
addformAddPosting
function. Here we should be re-instantiating typeahead.I could do a PR, but I really wouldn't know how to start the server for testing.