Hardt-Coded / Terminal.Gui.Elmish

An elmish wrapper around Miguel de Icaza's 'Gui.cs' https://github.com/migueldeicaza/gui.cs including a fable like view DSL.
The Unlicense
221 stars 12 forks source link

Text field cursor behaviour #2

Closed misterspeedy closed 5 years ago

misterspeedy commented 5 years ago

Description

When a text field is edited with the cursor position somewhere other than the end of the field, the model-updating process ends up moving the text cursor to the end of the field.

Repro steps

Please provide the steps required to reproduce the problem

  1. Run the demo

  2. Go to the TextFields section

  3. Click in the middle of the Text field.

  4. Insert a character.

Expected behavior

Text cursor should remain after the last inserted character.

Actual behavior

Text cursor is now at the end of the field.

Known workarounds

This is an issue which affects other Elmish incarnations, because the OnChanged event of a field triggers a message, which triggers a model change, which changes the field value. In Fable browser apps (if I recall correctly) this can be worked around by setting the DefaultValue property instead of the Value property. It would be great to have a similar workaround here.

Related information

Hardt-Coded commented 5 years ago

Added a pull request to the Terminal.Gui project to get the proper preconditions to fix the bug inside my code.

https://github.com/migueldeicaza/gui.cs/pull/187

Hardt-Coded commented 5 years ago

The Pull Request on Miguel's side ia already merged! Waiting for a new nuget version.

misterspeedy commented 5 years ago

Amazing. Thanks!

Hardt-Coded commented 5 years ago

fixed :)