Jermolene / TiddlyWiki5

A self-contained JavaScript wiki for the browser, Node.js, AWS Lambda etc.
https://tiddlywiki.com/
Other
7.78k stars 1.16k forks source link

The default value of $edit-text not effect to $set #8259

Closed lilixiong2018 closed 2 weeks ago

lilixiong2018 commented 2 weeks ago

Describe the bug

Create a new tiddler named "Test search with prefix" as:

<$edit-text field="search" default="Release" tiddler="$:/temp/search" placeholder="enter prefix string to search" size="30"/>

<$set field=search name=term tiddler="$:/temp/search" >
<$list filter="[!is[system]prefix<term>!sort[created]limit[200]]" template="$:/core/ui/ListItemTemplate" emptyMessage="Not found."/>
</$set>

then reload TW and open the new tiddler which named "test search with prefix", it show word "Release" on editrbox, but the result of "search" tidders is ALL, not which that has prefix of "Release".

Expected behavior

When open the "Test search with prefix" tiddler, return tidders which that has prefix of "Release".

To Reproduce

  1. Create a new tiddler named "Test search with prefix" as:
<$edit-text field="search" default="Release" tiddler="$:/temp/search" placeholder="enter prefix string to search" size="30"/>

<$set field=search name=term tiddler="$:/temp/search" >
<$list filter="[!is[system]prefix<term>!sort[created]limit[200]]" template="$:/core/ui/ListItemTemplate" emptyMessage="Not found."/>
</$set>
  1. Reload TW.
  2. open "Test search with prefix" tidder.
  3. It should show tidders which has prefix "Release", not all the tidders.

Screenshots

image

If we use backspace to delete some characters, or add some characters, it works as normal.

TiddlyWiki Configuration

Desktop (please complete the following information):

Additional context

No response

Jermolene commented 2 weeks ago

Hi @lilixiong2018 thanks for the report.

What is going on is that if the <$edit-text> widget is used with a target tiddler that does not exist then although the default attribute value is displayed in the control it is not actually saved back to the tiddler until the user makes a modification. So the result is that the target tiddler is not created unless the value is changed from the default value.

The underlying architectural reason that it works like this is because our architecture does not not permit widgets to modify the wiki store when are displayed or refreshed. Modifications can only be made within event handlers.

lilixiong2018 commented 2 weeks ago

Thank you. I close this issue because of design constraint.