Skip to content

Use mode: "open" in search component attachShadow? #72

@jaywonchung

Description

@jaywonchung

I'm on Chrome with the Vimium plugin, which allows people to navigate websites with vim-like keybindings like u, d, j, k, f, F, etc.

I noticed a very subtle issue in Zensical's search overlay (cmd-k/ctrl-k), where Vimium was not able to detect the fact that the cursor is activated within an input element. Normally it can and will disable keybindings, so pressing j will insert the character j in the input box instead of scrolling down. I've been using Vimium for 5+ years and this works very reliably, so I was surprised when this didn't work for Zensical's search overlay input box.

I realized that this is due to the following:

// Create a shadow root and inject search
const shadow = host.attachShadow({ mode: "closed" })
shadow.appendChild(h("style", {}, css.toString()))

Using mode: "closed" basically prevents external access to the elements inside, and thus Vimium is not able to inspect the HTML elements and figure out that an input element is focused.

I verified this by building my doc site with Zensical (0.0.23) and manually modifying site/assets/javascripts/bundle.5fcf0de6.min.js to use mode: "open" for the search component, and Vimium was indeed able to detect the input box and disable keybindings like usual.

I don't know if the use of mode: "closed" was intended. Would you be open to switching to mode: "open"? I'll post a PR if so.

Thanks.

cc. @squidfunk

Metadata

Metadata

Assignees

No one assigned

    Labels

    change requestIssue requests a new feature or improvement

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions