Ideally it would be handy if this option it was still active the first time I create a new tiddler. (i.e. when I click the “+” button)
But then when I’m editing a tiddler I find it awkward, especially because some actions force the activation of this focus, perhaps by scrolling a dozen tiddlers to go to the title of the one that I left in edit some time ago, and forcing me to scroll up to find where I was left.
An example of these actions is the a button that switches between a light and dark palette, or more generally when you switch palettes, but it happened also in other occasions that I couldn’t replicate now.
In general I find this option inconvenient. Is there a way to disable it?
Hi @SnapSam there’s currently no way to prevent the focus being given to newly created tiddlers, but there is a select box in control panel that allows the field that is focussed by default to be customised.
See control panel → Info → Basics and look for “Default focus field for new tiddlers”
Hello, I feel really privileged to be able to write to you. Thank you for the reply, but perhaps I have explained myself badly.
The fact that a focus is given to the “title” field of a newly created tiddler is a desirable thing, the thing I would like to avoid is that when I’m editing a tiddler and I perform certain actions the focus moves to the title of the tiddler I’m editing.
I don’t know how to explain it exactly, but it’s easy to replicate it. You can quickly test it on https://tiddlywiki.com/: if you edit “GettingStarted” and scroll away from there and then change palette, the focus will be put on the title of “GettingStarted” in the editor. (This is the “focus” I would like to avoid)
I reproduced this as you illustrated. I think it is jumping to the last edited tiddler and selecting the title, thus losing the position of the cursor.
My guess, with a little experimentation, is clicking the pallet selector changes the position of the cursor but jumps to the last tiddler in the story and selects the title.
When you select a new pallet $:/snippets/paletteswitcher then $:/core/ui/ControlPanel/Palette uses some reveal widgets to display the palet editor belowand that is affecting the focus.
[Edited] I notice a bug listed on the prerelease says;
fixed bug whereby scrolling occurs if the linkcatcher widget triggers an action-navigate and the $scroll attribute is set to “no”
I observed the linkcatcher widget is in use in the palet handling, however the “bug” you pointed out is still occurring in the pre-release.
Perhaps this is something for the devs and/or @jeremyruston
That’s actually the exact same thing. So you can not have one without the other. The title-input has an attribute set to “autofocus”. So as soon as it is rendered, this input field will “catch” the focus.
Changing the palette activates a complete page re-render. So the last input-field that is rendered and has the “autofocus” field set, will get the focus.
So we probably could set ControlPanel → Info → Basics → Default focus field to “none”, but that would also disable the “autofocus” if you create a new tiddler.
I have followed your instructions and set Default focus field to “none”, but when I click New Tiddler Button, the focus still changes. How do I avoid that focus change completely (or at least put the New Tiddler Edit pane next to the current tiddler I’m viewing or editing)?
Thanks for your explanation, with your hints info, I’ve finally implemented the navigation behavior I wanted: when there are tiddlers A, B, C in the Story River, I give B focus, then click add new tiddler button, the New Tidder will appear below B ➠ A, B, New, C.
❶ Install the Focussed Tiddler plugin by @Sttotfrom here
❷ Modify the $:/core/modules/widgets/navigator.js like this:
// Update the story to insert the new draft at the top and remove any existing tiddler
if(storyList && storyList.indexOf(draftTitle) === -1) {
// Get the current value of the tiddler in focus
var focusedPtr = this.wiki.getTiddler("$:/temp/focussedTiddler");
var focusedTitle = focusedPtr.fields.text;
var focusedTidIdx = storyList.indexOf(focusedTitle);
var slot = storyList.indexOf(event.navigateFromTitle);
if(focusedTidIdx !== -1) {
slot = focusedTidIdx;
} else {
if (slot === -1) {
slot = this.getAttribute("openLinkFromOutsideRiver","top") === "bottom" ? storyList.length - 1 : slot;
}
}
storyList.splice(slot + 1,0,draftTitle);
}
if(storyList && storyList.indexOf(title) !== -1) {
storyList.splice(storyList.indexOf(title),1);
}
I know it’s unwise to override shadow tiddlers in $:/core, but for now I don’t know any easier approach to implement this…
Thanks again for your code sharing, this is much better than my hacky version!
By the way, could I trigger this action $:/core/ui/Actions/new-tiddler from within a JavaScript macro source file? I have installed a contexmenu plugin and it also has a create new tiddler action, I want to use $:/core/ui/Actions/new-tiddler to replace that, is that possible?
Below is what I’m using now, whose behavior is inconsistent with $:/core/ui/Actions/new-tiddler
The code-snippet below is not enough context. There must be an event handler somewhere. I thin there are no tm-xxx messages, that can trigger arbitrary action code.
Do you have a link to the code or the modified plugin, that you use atm?