GithubHelp home page GithubHelp logo

Comments (5)

danice avatar danice commented on July 26, 2024 1

First, to use last version of materialize, you should use scripts from
https://www.jsdelivr.com/package/npm/@materializecss/materialize

For the shadow-dom problem, I think it is because card component is using this for the click event:

document.addEventListener("DOMContentLoaded", () => {
      document.body.addEventListener('click', e => {
        const trigger = <HTMLElement>e.target;

        const card: HTMLElement = trigger.closest('.card');
        if (!card) return;

And the target element in a shadow-dom is the shadowRoot, not the card element (see Shadow DOM and events)

I'm not sure of what will be the solution. Maybe the proper solution will be to convert every component to a custom element but this would be a big change and I'm not sure of the implications.

from materialize.

Lord-Leonard avatar Lord-Leonard commented on July 26, 2024 1

Well, thanks for the Info :) I will try to See What I can do with that.

from materialize.

LoganTann avatar LoganTann commented on July 26, 2024

Hi, I feel bad for around 10 months of inactivity.
I can see well in the dev tools that the card don't register an event inside a shadow root. About the waves, it might be similar.

As explained in the original issues, this might be related to how materialize selects events.
Unfortunately I don't know enough, and I don't have free time to investigate more. Added the bug label.

Feel free to reply if you can help to any ways.

from materialize.

Lord-Leonard avatar Lord-Leonard commented on July 26, 2024

Is there any plan on supporting webcomponents, especially the shadow root?

from materialize.

danice avatar danice commented on July 26, 2024

A possible solution could be this:

change the static init of the components:

static Init() {
    document.addEventListener("DOMContentLoaded", () => {
      document.body.addEventListener('click', e => {
        const trigger = <HTMLElement>e.target;

with something like this:

static Init(rootElement = null) {
   if (rootElement == null)
     rootElement = document.body
   document.addEventListener("DOMContentLoaded", () => {
      rootElement.addEventListener('click', e => {
        const trigger = <HTMLElement>e.target;

This will maintain backward compatibility and you can call the init method with the shadowRoot (for each card in a different shadow DOM).

from materialize.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.