$edit-text loses focus on input... or does it?

72 views
Skip to first unread message

Eric Shulman

unread,
Aug 3, 2021, 10:51:31 PM8/3/21
to TiddlyWiki
As we well know, when $edit-text targets the current tiddler and you start typing, the input control loses focus with each keystroke.

But... I just did an experiment with some very curious results...

Enter the following into a tiddler:
<$tiddler tiddler="target">
TEST1: <$edit-text tag="input" default=""/>
</$tiddler>

<$list filter="[[target]]">
TEST2: <$edit-text tag="input" default=""/>
</$list>

<$list filter="[[target]is[missing]]">
   <$link/> DOES NOT EXIST
</$list>
<$list filter="[[target]is[tiddler]]">
   <$link/> EXISTS
   <$button>delete target <$action-deletetiddler $tiddler=<<currentTiddler>>/></$button>
</$list>

target tiddler contents:
<pre>{{target}}</pre>

Note that TEST1 uses $tiddler to set the currentTiddler value, while the TEST2 uses $list to do the same thing.  The difference in behavior is that, when the target tiddler is missing, TEST1 creates the tiddler and loses focus on first keystroke, but TEST2 creates the tiddler and keeps focus on first keystroke.  Note that once the tiddler exists, you can type into either input control and neither one loses focus.

Can anyone explain what is happening?

TW Tones

unread,
Aug 4, 2021, 1:13:30 AM8/4/21
to TiddlyWiki
Eric,

I cant explain this and its an interesting observation. There are similar cases I have seen where entering text, that results in a new tiddler causes a delay, if not a loss of focus, but not in other cases. This may have something to do with that.

Of course your example is using one tiddler to edit another, where the focus issue has being my concern, is to allow one to edit fields or text in the current visible tiddler. This works well once working, however it is quite fragile and involves view templates, nesting and macros that I have not quite documented or mastered. Perhaps there are aspects to what you have demonstrated that makes this so fragile, that there are subtle and undocumented issues that can manifest problems.

Tones

PMario

unread,
Aug 4, 2021, 4:33:13 AM8/4/21
to TiddlyWiki
Hi Eric,

I think it's because the tiddler-widget does much more and different things as the list widget. See the code: https://github.com/Jermolene/TiddlyWiki5/blob/8e69284e8c6b99a6aa8d3d1001d5a1920d814a9c/core/modules/widgets/tiddler.js#L91 see the  newTiddlerState.hash condition

When the "target" tiddler is created, imo the tiddler-widget refresh is triggered by the core change-event, which causes a redraw of the tiddler-widget. .. When the tiddler exists, imo the refresh isn't triggered anymore since the "tiddler parameter" didn't change

-mario

Reply all
Reply to author
Forward
0 new messages