Some change in TW 5.2.4 broke my plugin tw5-keyboard-navigation

Yesterday, I upgraded TiddlyWiki from version 5.2.3 to 5.3.0. Quickly, I noticed that my plugin tw5-keyboard-navigation (Source code) doesn’t work anymore.

Usually, it works like that: When I press j or k, I can jump to the next/previous tiddler, except when the active element is a textarea or an input element, p.e. when I edit a tiddler. Then, the onkeydown function returns right at the beginning.

But in TiddlyWiki 5.3.0 and all versions since 5.2.4, the viewport jumps up and down while I’m editing a tiddler.

Any ideas what could be wrong? Or which change in TW 5.2.4 could be related?

What’s also strange: When I disable my plugin, I get a pop up window about an “Internal JavaScript error: TypeError: tiddlerCycle is undefined” when I type. This is a variable used in the plugin. I don’t understand how it can cause an error when the plugin is disabled. This happens even after killing the TiddlyWiki server and starting it again (with the plugin still disabled).

Perhaps change the title to “Some change in TW 5.3.0…” it is TW 5.3.0 that needs a fix and 5.3.1 will be out soon. If there is a bug it needs fixing, either the plugin or tiddlywiki.

I can’t find how to edit the title.

If you edit your original post, you should be able to edit the title.

BTW, the fact of the problem starting in TW 5.2.4, that’s info that will help pinpoint the problem (if it still exists) in the pending new version of TiddlyWiki.

However you alter the title, I think it is immensely important to not lose that awesome bit of info (i.e. since version 5.2.4 and still existing in the latest and greatest?)

I can’t even find how to edit my post :slight_smile:
Maybe I don’t have the rights to do so? When I hover over the trash can, at least I see that I don’t have the permission to delete my post.

I also think that it could make it more difficult to find the root cause for my problem when I change the title to “Some change in TW 5.3.0…”.

Maybe somebody can tell if this is a bug in TiddlyWiki. Then I would create an issue at GitHub. Or somebody tells me that some hooks have changed. Then I probably would only have to update my plugin.

You edit the title differently to the posts and replys

See here at the end of the title.

Of course I was looking for something like a pen icon. It’s just not there for me:

(You can see in the top right corner that I’m logged in.)

I suspect the underlying issue might be that as part of enhancing the customizability of the core keyboard shortcut mechanism, keyboard events from the iframe of the editor are now propagated to the parent document.

See:

1 Like

Thank you. This sounds like it could help. But I couldn’t find yet how I can use this to fix my plugin. I have no j or k shortcut mapped in the control panel. Maybe it helps when I do this…

I think there has been a bit of an oversight in that PR with regards to the backwards compatibility implications. None of us considered the use case where one doesn’t want the keyboard event to propagate to the parent, mostly because keyboard shortcuts usually use a modifier key.

Your options include changing the shortcuts to use a modifier key such as ALT to trigger your shortcuts avoid having then triggered from the editor, or modifying the event listener to ignore events whose target is an input or textarea element, or have been propagated from an iframe.

Thank you!
I don’t want to use a modifier key (I rather stay on TiddlyWiki 5.2.3 in this case). My plugin already ignores events whose target is an input or textarea.

or have been propagated from an iframe.

This seems to be the way to go for me. Could you give me a hint how to recognize such a key event?

@saqimtiaz: Maybe this is not exactly what you meant:

if (e.target.className == "tc-tiddler-preview")
    return;

But it seems to work (in TW 5.3.0).

I needed another change (see this commit). Now the plugin is usable again in TW 5.3.0.

But this issue remains:

When I disable my plugin, I get a pop up window about an “Internal JavaScript error: TypeError: tiddlerCycle is undefined” when I type. This is a variable used in the plugin. I don’t understand how it can cause an error when the plugin is disabled. This happens even after killing the TiddlyWiki server and starting it again (with the plugin still disabled).

Did you test it with the TW-prerelease? https://tiddlywiki.com/prerelease/ or latest github master branch?

I have tested it in TW 5.3.0 and the master branch.

UPDATE: I have tested it successfully in the prerelease.

3 Likes