This is a stripped-down version of a single section of Grok TiddlyWiki, optimized for fast loading and readability by search engines. Some features are missing.

For the full Grok TiddlyWiki experience, please visit the wiki version of this page.

Ex:EditCurrentTiddler/answer

18th August 2021 at 2:19pm

Quick and easy:

<$edit-text tiddler=<<currentTiddler>> field="userwhoclicked" tag="input" default=""/>

A historical note that continues to have both practical and pedagogical relevance: Before TiddlyWiki 5.2.0, it was impractical to directly edit a field on the current tiddler, as the text box would lose focus every time you typed a single character, making typing anything into it infuriating. For this reason, when you browse existing wikis or look at old sample code, you may still see temporary tiddlers being used as the targets of edit boxes where they don't look like they would be useful.

To understand why this happened previously, recall that whenever we make any change in the wiki, it is immediately reflected elsewhere – for instance, a tiddler that is changed so that it newly matches a filter will immediately show up in any lists that use that filter. TiddlyWiki does this by notifying each widget displayed on the screen that a tiddler has changed and giving it a chance to refresh itself if it thinks it might need to display something different as a result of that tiddler changing. (Specifically, the root widget, at the "top" of the wiki, sends the news to all of its immediate child widgets, like the sidebar and the story river, then each of those transmit the news to their children, and so on until the message has propagated everywhere it is relevant.)

In versions prior to 5.2.0, anytime any field on a tiddler was changed, all transclusions of that tiddler were refreshed. That included the display of the whole tiddler in the story river and all its contents, since tiddlers are displayed in the story river by transcluding them through a template. The display of the tiddler in the story river of course included the edit widget – and when a text box is removed from the page and re-rendered, its focus is lost.

In 5.2.0, the refresh mechanism has been improved so that transclusions of a tiddler are only refreshed when the specific field being transcluded has changed. This change not only avoids unnecessary refreshes and improve performance, it also prevents this lost-focus issue – since the text box is included within the text field of the tiddler specifically, changing any other field using the text box won't trigger a refresh of the widget.

Go to question: Ex:EditCurrentTiddler