When the `$:/temp/BAM/Settings` tiddler is first created, it causes 
everything following the `$tiddler` widget to be refreshed, which triggers 
the loss-of-focus that you observed.  While creating the temporary tiddler 
on startup certainly does fix this issue, there is another solution that 
doesn't require a startup action.  Just move the `$tiddler` widget AFTER 
the `$edit-text` widget and add a `tiddler=...` parameter to the 
`$edit-text` widget, like this:
```
<$edit-text tiddler="$:/temp/BAM/Settings" field="search_draft"/>
<$tiddler tiddler="$:/temp/BAM/Settings">
```
Thus, the `$edit-text` widget is no longer subjected to the spontaneous 
refresh when the temp tiddler is first created, but everything else still 
works as before.

Another way to achieve this same result is to replace the `$tiddler` widget 
with
```
<$list filter="$:/temp/BAM/Settings">
```
which has the side effect of setting the `currentTiddler` value to 
`$:/temp/BAM/Settings`, but doesn't cause the loss-of-focus refresh to be 
triggered.

enjoy,
-e
On Friday, February 3, 2023 at 10:25:21 AM UTC-8 [email protected] wrote:

> I've got a search field that only takes effect after clicking an "Apply" 
> button.
>
> ```
> <$tiddler tiddler="$:/temp/BAM/Settings">
> <$edit-text field="search_draft"/>
> <$button class={{{ [{!!search_draft}!match{!!search}then[blinking]] }}} 
> disabled={{{ [{!!search_draft}match{!!search}then[yes]else[no]] }}}>
> <$action-setfield search={{!!search_draft}}/>
> Apply
> </$button>
> ```
>
> Every time, the first time entering text in that search field, the focus 
> would move away from the field right after typing the first character.
>
> Never any focus issue after that first-time-first-keypress every time I 
> used the TiddlyWiki instance.
>
> The problem: the temporary tiddler, which doesn't exist until something is 
> typed in the field, gets created on the first keypress in that field.  That 
> causes the focus to move away from the field.
>
> What I did: create that temporary tiddler on Startup of the TiddlyWiki 
> instance.
>
> Problem solved.
>

-- 
You received this message because you are subscribed to the Google Groups 
"TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywiki/5688284c-7583-4fae-bb3a-8008062d94c0n%40googlegroups.com.

Reply via email to