- Sponsor
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Add support for Custom Element #6652
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Thanks for reporting. Please provide a reproduction that showcases the issues. We cannot merge a PR without knowing what it impacts and for that we need to see it in action. |
I have a pretty similar issue and I asked about a possibility to disable the hotkeys in Material for MkDocs but I was told the only way to do it currently it by removing that chunk of code and re-compile the theme 😞 : #4273 I'm also working with Custom Elements that contain inputs/forms inside them and this is a problem since every time that |
We can make hotkeys configurable in the future, but it is currently not a priority for us, so no ETA. |
If you use |
To workaround the issue, I added a |
I can confirm that this fix works for me. I created a small example at https://test-builds.readthedocs.io/en/mkdocs-material/ and opening the search modal ( |
Context
I added Custom Elements with shadow root via custom elements because I don't want the styles of mkdocs has influence on forms I am adding. When I have a form inside my custom component, the global keyboard handler catches some keys I am typing like
s
and takes focus to search.The reason is if there is input focused inside the shadow root, the parent's
document.activeElement
would point to the custom element itself, not to it's underlying element.Since 'the bug' is caused by extra javascript, I cannot mark it as a bug, so I am asking about adding support for custom elements.
Description
While having additional functionality via extra_javascript is a great feature, it lacks a full support for adding custom elements. I was able to add the custom element, but the keyboard shortcut is not aware about such type of element.
There is a check for activeElement which works differently for elements with shadowRoot. I am asking to add support for such kind of elements here:
mkdocs-material/src/templates/assets/javascripts/browser/element/_/index.ts
Lines 116 to 120 in 4498245
The active element of shadowRoot can be accessed via
document.activeElement.shadowRoot.activeElement
.Related links
Use Cases
It will allow to have forms inside custom elements
Visuals
No response
Before submitting
The text was updated successfully, but these errors were encountered: