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.