pjeby / tag-wrangler

Rename, merge, toggle, and search tags from the Obsidian tag pane
633 stars 19 forks source link

Make Context menu available on Mobile preview/live mode #138

Open codey-badger opened 4 months ago

codey-badger commented 4 months ago

Hi, First, thanks for the awesome plugin, it's very useful, it should be a core functionality.

Now, as the title says It would be even better if the Context menu were available on Mobile preview/live mode. Changing to reading view stops the flow when processing the notes. preview/live mode probably is the most common view used by default.

TIA for your time.

pjeby commented 4 months ago

I don't have/use Obsidian on mobile, but on the desktop if I put Obsidian in mobile emulation it comes up just fine. Do note that the context menu will include all the usual context menu items, but "Rename", "Create tag page", "Search", etc. will be at the end.

If it's not working on actual mobile I have no clue what's going on. If it's working in reading view and in the sidebar then Tag Wrangler is definitely running, so I've no idea why it wouldn't work in the context menu in editing mode. (I even tried shrinking my screen to make less room for the menu, and it still shows up, but on a sufficiently small screen you might need to scroll the context menu to see the TW-added items.)

codey-badger commented 4 months ago

In my case it's the other way around, just on mobile.

Maybe it happens just on Android. I will leave some images in case somebody has the same problem. Let me know it is ok.

Preview/ live view: Screenshot_20240701-192607_Obsidian

Reading view: Screenshot_20240701-192707_Obsidian

pjeby commented 4 months ago

This is what I get in mobile emulation, on 1.5.8, 1.6.3, and 1.6.5, in the sandbox:

image

I'm not sure what to suggest here. Did it work in any previous version of Obsidian?

codey-badger commented 1 month ago

Hi @pjeby , here again, I was wondering the same, maybe a release changed the behavior. Regardless, today I can reproduce the 'bug' consistently, maybe it's working as expected but let me know if something can be done.

When using it in mobile (not the emulation) the context menu is shown as expected with all the options as long as the cursor is right next to the tag of interest. If there's a blank space, or the cursor is positioned in other place of the page, the options of the plugin won't appear after a long press tap.

That's why I'm 'forced' to interrupt workflow and change my view or editing mode given that tapping near the tag will initiate the native 'search tag' function. In 'reading view' this won't happen as the cursor probably is not active.

pjeby commented 1 month ago

If you long-press a tag with the cursor elsewhere, what happens? Does it do the same w/TW disabled?

Arguably, if you can't get a context menu from long-press on a tag at all (with or without TW enabled), unless the cursor is already in it (or if the context menu is actually for the spot where the cursor is), that'd be an Obsidian bug that you can report. Especially since the behavior is correct in mobile emulation, that seems like a divergence in the mobile version.

codey-badger commented 1 month ago

It's just the TW options that are not shown, this happens to me when the cursor is not right next to the tag. If the long tap happens when the cursor is between, or right next to the tag, it works.

Here's a short video to make it clear (same behavior in a new vault with default settings no community plugins except TW installed and enabled). Thanks in advance.

https://github.com/user-attachments/assets/71629c42-d6e8-4ed9-a496-22e5be38f46d

pjeby commented 1 month ago

At 0:03 in your video a context menu appears, and it has items that are off-screen for some reason. Have you tried scrolling or dragging it up to see what else is on there?

If nothing else, it looks like an Obsidian issue with being able to see/access the whole menu.

codey-badger commented 1 month ago

Those extra commands where added with Commander plugin. I have tried to scroll but the TW options doesn't appear, after long press tap, unless the cursor is specifically between the tag itself or right next to it.

In this way, it is not the context menu itself but the TW commands. Let me known a better title for the issue, maybe: TW commands doesn't appear in context menu after long press tapping when the cursor is not in the tag itself?

Here's the same behavior in a vault with no other community plugins:

https://github.com/user-attachments/assets/23906c93-170c-44b4-851f-61da951bf909

I will ask in the forum later but the behavior is as expected with core Obsidian and the same with other community-plugins-commands that interact with the context/menu editor.

Thanks for your time.

pjeby commented 1 month ago

So my guess at this point then is that in mobile emulation, right-clicking first sets the cursor on the tag, while on the actual mobile device, long-press does not set the cursor on the tag first. That would explain why the behavior's different.

Let me ask you this: if your cursor is not on a heading, but you long-press in a heading, do you get options like "bookmark this heading", and "rename this heading"?

codey-badger commented 1 month ago

if your cursor is not on a heading, but you long-press in a heading, do you get options like "bookmark this heading", and "rename this heading"?

No, I don't get the options.

Thanks for pointing it out, I really don't use that commands so I didn't notice. If the cursor it's somewhere in the heading section, the options("bookmark this heading", and "rename this heading") are shown after long-pressing a link or a tag in the heading. If the cursor it's elsewhere outside the heading the options are not shown.

https://github.com/user-attachments/assets/f5410718-f241-4f22-a272-f46b732c3d5c

The behavior from the video it's reproducible with and without TW enabled. Pls, if possible, let me know how would you title the post for the forum, I will edit and post it ASAP with the gathered information.

Sorry if it's too much videos.

pjeby commented 1 month ago

I would frame the bug report as "Long press on mobile does not set cursor position before triggering context menu", giving the header thing as an example and noting that it also affects other plugins that provide editor-menu enhancements and expect the cursor position to match the long-press position.

A possibly-related bug that still existed in 1.5.8 desktop, but seems to be fixed on 1.7 desktop at least: https://forum.obsidian.md/t/context-menu-on-link-does-not-correctly-position-cursor-in-live-preview-on-task-switch/65315