[TW5] edit-text defocusing on input

109 views
Skip to first unread message

Irene Knapp

unread,
Jan 13, 2014, 12:18:10 AM1/13/14
to tiddly...@googlegroups.com
Hi,

So - for a TiddlyWiki (five, of course) that I'm using for a personal project, I am attempting to set up something that superficially resembles a relational database (except not in the backend, of course - I don't expect the data to grow large enough for the performance issues to matter).  I want there to be a whole family of tags each of which, when present, indicates that there should be a specific collection of field editors, comprising a form, at the top of the tiddler.  I've got this mostly working:

<$cond p="[tag[Ability]]"><h2>Ability Details</h2>
<div class="form">
<h3>Inputs</h3>
<$edit-text field="data/Ability/inputs" class="tw-edit-texteditor" tag="textarea"/>
<h3>Expected Outputs</h3>
<$edit-text field="data/Ability/outputs" class="tw-edit-texteditor" tag="textarea"/>
<h3>Expected ~Side-Effects</h3>
<$edit-text field="data/Ability/side-effects" class="tw-edit-texteditor" tag="textarea"/>
</div></$cond>

... As an example of one such form; the above is the source text of a tiddler which is indirectly included in the edit template.  (That $cond is a macro of my own authorship, but you can see what it's doing.  I'd have contributed it, but I feel as though using the filter mechanism for arbitrary predicates is rather messy, and would rather have a better approach...)  There's a similar one for view, which works perfectly, but it's edit that I'm having trouble with...

It uses the $edit-text macro to insert widgets for each of three side-channel fields in the tiddler being edited.  They appear to correctly display the values of those fields, and to be updated appropriately as those values change.  The problem I'm having is that typing any input character (text only - arrow keys and other movement shortcuts work fine) causes the input field to lose focus and the page to scroll down to the "fields" section of the edit display, below.

I assume that this has something to do with the events mechanism, but I'm a little lost in the code...  I looked at the source of $:/core/modules/widgets/edit-text.js, and noted that it has some events stuff and some scroll stuff, which I assume are scoped too broadly, causing the misbehavior I'm encountering.  But I'm at a loss for where those events are dispatched from, or what their scoping ought to be.  I can't find the code that implements the event-dispatch mechanism, either.

Any advice would be appreciated. :)

Irene

Stephan Hradek

unread,
Jan 13, 2014, 3:36:26 AM1/13/14
to tiddly...@googlegroups.com
It is a known issue. As soon as you edit a field, each change is followed by a refresh. So if you are editing a field of the current tiddler, the tiddler gets refreshed every keystroke. You need to edit fields of another tiddler at the moment.

Jeremy Ruston

unread,
Jan 13, 2014, 8:02:03 AM1/13/14
to TiddlyWikiDev
Hi Irene

The root of the issue is that the transclude widget always refreshes itself if the target tiddler changes. So, consider transcluding the text of a tiddler and within it there is an edit widget displaying a different field of the same tiddler. When the edit widget modifies that field the transclude widget notices the change and refreshes itself, causing all the transcluded content to be re-rendered, including the edit widget.

The best way around it I can see is for the transclude widget to retain the previous text of the field/index being rendered, and then do a further check in refresh() to avoid refreshing the transclusion if the text has not in fact changed from its previous value. I've created a ticket to keep track:


Many thanks,

Jeremy


On Mon, Jan 13, 2014 at 8:36 AM, Stephan Hradek <stephan...@gmail.com> wrote:
It is a known issue. As soon as you edit a field, each change is followed by a refresh. So if you are editing a field of the current tiddler, the tiddler gets refreshed every keystroke. You need to edit fields of another tiddler at the moment.

--
You received this message because you are subscribed to the Google Groups "TiddlyWikiDev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tiddlywikide...@googlegroups.com.
To post to this group, send email to tiddly...@googlegroups.com.
Visit this group at http://groups.google.com/group/tiddlywikidev.
For more options, visit https://groups.google.com/groups/opt_out.



--
Jeremy Ruston
mailto:jeremy...@gmail.com

Stephan Hradek

unread,
Jan 13, 2014, 9:25:12 AM1/13/14
to tiddly...@googlegroups.com
No idea whether it helps. Check "Creating a simple Contacts DB" on http://tw5magick.tiddlyspot.com/

I'm transcluding in a tiddler called "Person DB" tiddlers having some contact detail fields, using an edit template which allows editing of those fields.
Reply all
Reply to author
Forward
0 new messages