[tw5] EditTextWidget and the "trap"

From https://tiddlywiki.com/#EditTextWidget:

One trap to be aware of is that the edit text widget cannot be used to edit a field of the tiddler that contains it. Each keypress results in the tiddler being re-rendered, which loses the cursor position within the text field.

I thought that was resolved in TW5.2.0. Based on current documentation, me thinks I likely misunderstood whether or not TW5.2.0 resolved the “trap.”

Regardless, do note: in some circumstances, the trap does not apply. However, in other circumstances, the trap does apply. Although not a problem in certain circumstances, I’m thinking best to always avoid use of edit text widget to edit a field of a tiddler in which the edit text widget exists.

Please download the attached and drag into TiddlyWiki.com to be aware of the trap.

Apologies if I missed any already existing discussion about this.

EditTextWidget Tester.json (594 Bytes)

Hi Charlie,

From https://tiddlywiki.com/#EditTextWidget:

One trap to be aware of is that the edit text widget cannot be used to edit a field of the tiddler that contains it. Each keypress results in the tiddler being re-rendered, which loses the cursor position within the text field.

I thought that was resolved in TW5.2.0. Based on current documentation, me thinks I likely misunderstood whether or not TW5.2.0 resolved the “trap.”

Good catch, we missed that. I’ve updated the docs to reflect the changes in v5.2.0.

Regardless, do note: in some circumstances, the trap does not apply. However, in other circumstances, the trap does apply. Although not a problem in certain circumstances, I’m thinking best to always avoid use of edit text widget to edit a field of a tiddler in which the edit text widget exists.

Please download the attached and drag into TiddlyWiki.com to be aware of the trap.

Apologies if I missed any already existing discussion about this.

The second example in your test tiddler looks like this:

<$vars var2={{!!field2}}>

‘‘Field 2:’’

<$edit-text field=“field2” />

Field 2:<$text text={{{[get[field2]] }}}/>

</$vars>

The problem here is actually not the <$edit-text> widget but the <$vars> widget – it (and all the widgets it contains) gets refreshed each time the value of field2 changes.

Best wishes

Jeremy.