Field loses focus after a few seconds of editing

164 views
Skip to first unread message

Mat

unread,
Apr 10, 2017, 10:33:34 AM4/10/17
to TiddlyWiki
This not yet released plugin; searchwords works very well except that when entering text in the special searchwords field... which is really just a regular field but moved... the focus is lost after a few seconds. (Note, it does not loose focus after each character like when tiddler refresh is triggered from other contexts.)

Any ideas...? It will be a useful plugin once finished.

<:-)


Mark S.

unread,
Apr 10, 2017, 2:21:16 PM4/10/17
to TiddlyWiki
Without looking at your code, I'm thinking that it might be a variation of this problem (from the <$edit-text> docs:


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'm going to be interested in how you got the search engine to look in other fields. I would like the standard search engine to check the caption field.

Good luck!
Mark

Mat

unread,
Apr 10, 2017, 4:41:55 PM4/10/17
to TiddlyWiki
Thanks Mark but that is exactly the "trap" I do NOT think is the problem here because it is not "each keypress that results in re-rendering". Rather, the loss of focus comes after a little while during writing.

Or, might I be misunderstanding something?

<:-)

Mat

unread,
Apr 10, 2017, 5:01:36 PM4/10/17
to TiddlyWiki
And, regarding


I'm going to be interested in how you got the search engine to look in other fields. I would like the standard search engine to check the caption field.

If you look in the default About tiddler, in the Components tab, you'll see I list two modified core tiddlers. So, unfortunately that is what it took. It would be nice if we could hook into the search filter with some parameter. If you want, I think that would be a worthy github request or PR because people do want to search other fields. And probably simple to implement too.

<:-)

Mark S.

unread,
Apr 10, 2017, 6:34:24 PM4/10/17
to TiddlyWiki
I guess what I really want to change is the search filter operator itself, so additional fields can be added to the standard search. "caption", for instance, should have the same standing as "title" IMO. This would allow us to get away from ever having to change title (which breaks linking and TOCs).

Thanks!
Mark.

Thomas Elmiger

unread,
Apr 10, 2017, 7:35:45 PM4/10/17
to TiddlyWiki
Hi Mat

This works, no idea why:

<$edit-text field="searchwords" class="tc-titlebar tc-edit-texteditor" focus="true"/>

I hope you will find the (relevant) difference to your field …

All the best, Thomas

Mat

unread,
Apr 11, 2017, 5:34:24 AM4/11/17
to TiddlyWiki
Thanks Thomas, but unfortunately it still loses focus with focus=true  but, after unfocus, immediately refocuses on the field which makes the entered text become overwritten.

I'm starting to think the "typing refresh delay" might be a clue. I don't really understand where that setting has an effect  Setting it to 0 doesn't seem to change anything. I'll raise a separate discussion on this.

<:-)

Thomas Elmiger

unread,
Apr 11, 2017, 8:39:59 AM4/11/17
to TiddlyWiki
Hi again Mat

What i meant was: if you insert my field in your plugin’s .../main tiddler (and remove the focus from your own field) then my field actually works! (Tested on my iPhone in Safari.)

Put this in your main tiddler and you will see:

\define searchpath() $(currentTiddler)$!!searchwords
\define def() $(sw)$

<$list filter="[<currentTiddler>!has[searchwords]]">
<$button class="searchwords-toggle tc-btn-invisible"
set=<<searchpath>>
setTo=" " tooltip="Add searchwords">
{{$:/core/images/advanced-search-button}}
</$button>
</$list>

<$list filter="[<currentTiddler>has[searchwords]get[searchwords]]"
variable="sw">
<div class="searchwords-area tc-edit-tags ">
<span class="searchwords-info">?</span>
<$edit-text class="searchwords-fld" tag=input
field=searchwords
/>
<$button class="tc-btn-invisible searchwords-btn"
tooltip={{$:/language/EditTemplate/Field/Remove/Hint}}
aria-label={{$:/language/EditTemplate/Field/Remove/Caption}} >
<$action-deletefield $field="searchwords"/>
{{$:/core/images/delete-button}}
</$button>
</div>
<$edit-text field="searchwords" class="tc-titlebar tc-edit-texteditor" focus="true"/>
<style>.tc-edit-tags {padding-top: 1px; padding-bottom:1px;}</style>
</$list>

---

Cheers, Thomas
Message has been deleted

Mat

unread,
Apr 11, 2017, 3:58:55 PM4/11/17
to TiddlyWiki
Thomas.. I really appreciate your help but it doesn't seem to work. Here's a link where your solution is used and with a tiddler open in edit mode. If you type in text in "your" field... it still refreshes focus after a few seconds. I'm using Win10 and Chrome and FF. If you get it to work in the link I provide, what are you using?

Thank you Thomas!

<:-)

Thomas Elmiger

unread,
Apr 11, 2017, 4:50:25 PM4/11/17
to tiddl...@googlegroups.com
Hi Mat … I am currently trying to fix a similar problem – but I realise now, that only safari mobile on iOS gets it "right" so I guess it is kind of a safari mobile bug that gave me hope. I’ll come back if I find a solution.

:(
Thomas

--
You received this message because you are subscribed to a topic in the Google Groups "TiddlyWiki" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/tiddlywiki/LC1EwX7kiNM/unsubscribe.
To unsubscribe from this group and all its topics, send an email to tiddlywiki+unsubscribe@googlegroups.com.
To post to this group, send email to tiddl...@googlegroups.com.
Visit this group at https://groups.google.com/group/tiddlywiki.
To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywiki/2fc3a098-bd04-41bf-8d01-870a18ef9ec2%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Mark S.

unread,
Apr 11, 2017, 5:47:01 PM4/11/17
to TiddlyWiki
Hi Mat,

I think it has to do with the fact that the edit is changing the state of the <$list> it's in as you type. If you comment out the <$list> (e.g. <!--$list filter="[<currentTiddler>has[searchwords]get[searchwords]]"
         variable="sw"-->) so that the field is always open, you can type into it fine. This suggests that if you switched to a button with a reveal statement it might work as intended. I know this wouldn't be quite as magical as having it appear automatically, but it still wouldn't be bad.

BTW, I couldn't see where variable sw or macro def() were being used.

Good luck,

Mark

On Monday, April 10, 2017 at 7:33:34 AM UTC-7, Mat wrote:

Mat

unread,
Apr 14, 2017, 7:44:07 AM4/14/17
to TiddlyWiki
Mark, you were right! Plugin now works. Soon to be announced publicly.

Warm thanks to you and Thomas!!!

<:-)

Thomas Elmiger

unread,
Apr 14, 2017, 7:49:17 AM4/14/17
to TiddlyWiki
Mark, same here, you showed me the right way. Structuring input and output in a proper way solved the problem :–)

Thanks to both of you!
Thomas
Reply all
Reply to author
Forward
0 new messages