Keyboard shows up after toggling a checkbox in android

Steps to reproduce (in android)

  1. make a chekc box and type something
  2. close/hide your keyboard
  3. toggle the check box
    InShot_20250721_180228884

Did you follow the troubleshooting guide? [Y/N]

yes

Expected result

when you toggle the checkbox it should not show the keybkard

Actual result

it show the keyboard when you toggle the check box

Environment

SYSTEM INFO:
Operating system: android 14 (samsung SM-A725F)
Obsidian version: 1.8.10 (197)
API version: v1.8.10
Login status: not logged in
Language: en
Live preview: on
Base theme: adapt to system
Community theme: none
Snippets enabled: 0
Restricted mode: on

RECOMMENDATIONS:
none


Additional information

I think it’s related to this When keyboard is not showing hide the cursor ( mobile )

it just happenes when the cursor is showing on screen and the keyboard is hidden and you toggle a check box

This is related to this other BR:

also I tried it with my phone’s default keyboard and in another phone

I would say the main problem comes from android cause I have tested in other apps when you close your keyboard the cursor stays on screen but in some apps like xiaomi’s default note app when you close your keynoard the cursor gets hidden ( cause when you hide the cursor with toggling reading mode on and off and check a checkbox it will not happen)

debug info

SYSTEM INFO:
Operating system: android 14 (samsung SM-A725F)
Webview version: 138.0.7204.179
Obsidian version: 1.9.10 (234)
API version: v1.9.10
Login status: not logged in
Language: en
Live preview: on
Base theme: adapt to system
Community theme: none
Snippets enabled: 0
Restricted mode: on

RECOMMENDATIONS:
none

secpnd phone debug info

SYSTEM INFO:
Operating system: android 14 (Xiaomi 21081111RG)
Webview version: 138.0.7204.181
Obsidian version: 1.9.10 (234)
API version: v1.9.10
Login status: not logged in
Language: en
Live preview: on
Base theme: adapt to system
Community theme: none
Snippets enabled: 0
Restricted mode: on

RECOMMENDATIONS:
none

video

InShot_20250819_174919711

TLDR; If you want to immediately fix the issue, you can simply try installing the JavaScript Init plugin by ryanpcmcquen and paste the snippet below to the textbox in the plugin’s settings.

class CheckboxFix {
    // 1. Static property: This exists on the Class itself, not the instance, to prevent multiple listeners if the script re-runs
	static isRunning = false;

    constructor() {
        // 2. Check the static flag before doing anything
        if (CheckboxFix.isRunning) {
            console.log("CheckboxFix: Already active. Skipping initialization.");
            return;
        }
        
        this.init();
    }

    init() {
	    // Safe check for mobile environment
        const isMobile = window.activeLeaf?.view?.app?.isMobile || /Android|iPhone|iPad/i.test(navigator.userAgent);

        if (isMobile) {
            window.addEventListener('touchstart', (e) => {
                if (e.target && e.target.classList.contains('task-list-item-checkbox')) {
	                // 3. we prevent any default behaviors here, including the scroll
                    e.preventDefault(); 
                    e.stopPropagation();
                    // 4. Click the checkbox manually
                    e.target.click(); 
                    console.info("CheckboxFix: Native scroll blocked.");
                }
            }, { capture: true, passive: false });

			// Mark as initialized
            CheckboxFix.isRunning = true;
            console.info("CheckboxFix: Atomic Trap initialized successfully.");
        }
    }
}

// Instantiate the class
new CheckboxFix();

I also can still replicate the behaviour with the latest release 1.11.5. (Gotta admit I am pretty annoyed by this too)

The following code, as far as I am concerned, solves the problem described in the closed post that directed me here: Checking a checkbox jumps focus down (to the cursor)https://forum.obsidian.md/t/keyboard-shows-up-after-toggling-a-checkbox-in-android/103138

However I dug deeper to analyze the problem and looks like it is due to a very unforeseeable natural behavior of the CodeMirror 6 editor view in mobile: When one clicks on a checkbox in editor view, it triggers the android soft keyboard to pop from below (basically the keyboard shows), and it triggers a resize command to the obsidian editor. This is where this anomaly scroll event happens: when the view resizes, i.e. onResize triggers, it calls the scrool into view function to where the cursor is currently at. Basically the issue is, in mobile, the keyboard shows when you tap on the editor, this is the reason why it happens in Android. (I dont really know the internals of IOS, so I should not vouch for it).

Notice that this unwanted behavior doesn’t happen when the cursor is on a line that is already in the view, or if you tap on somewhere else on the line with the checkbox before to carry the cursor here, then tap on the checkbox.

This is very easily fixed with a tiny atomic (inseparable) function. I hope this will be integrated into obsidian core code for wider accessibility to the whole userbase.

For the interested: We essentially Implement a capture-phase listener on task-list elements (checkboxes) to intercept touchstart (taps on screen). By preventing default and manually dispatching the click, we bypass the native scroll-to-focus behavior while maintaining the toggle functionality.

The Solution: This can be implemented at the app level by intercepting the touchstart event in the Capture Phase. By preventing the default focus/scroll routine and manually dispatching the click, we bypass the native scroll-to-cursor logic entirely.

I have verified that this ‘Atomic’ intercept fixes the jump completely:

window.addEventListener('touchstart', (e) => {
    if (e.target.classList.contains('task-list-item-checkbox')) {
        e.preventDefault(); // Stop the native scroll-to-cursor/focus
        e.stopPropagation();
        e.target.click();   // Manually toggle the checkbox
    }
}, { capture: true, passive: false });

Hopefully, this logic can be integrated into the mobile core to finally close this long-standing UX issue.