openscd / open-scd-core

Apache License 2.0
5 stars 8 forks source link

Menu plugins are not visible #77

Closed danyill closed 1 year ago

danyill commented 1 year ago

When creating a menu plugin for open-scd-core, I was unable to bring the dialog to the foreground in either Firefox or Chrome.

Looking in the Chrome debugger tools, it was (eventually) noticed that the opacity was set to zero on the aside element and the plugin was inheriting this opacity: 0.

This is within the shadow-root of the open-scd element which has the structure:

<mwc-drawer id="menu"></mwc-drawer>
<mwc-dialog id="log"></mwc-dialog>
<aside>
    <oscd-{plugin-hash}>
    <oscd-{plugin-hash}>
    <oscd-{plugin-hash}>
    <oscd-{plugin-hash}>
</aside>

The constructed stylesheet for the aside element was:

aside {
    position: absolute;
    top: 0px;
    left: 0px;
    width: 0px;
    height: 0px;
    overflow: hidden;
    opacity: 0;
    margin: 0px;
    padding: 0px;
}

I resolved this in my plugin with:

  protected firstUpdated(): void {
    this.parentElement?.setAttribute('style', 'opacity: 1');
  }

Which restored visibility operation.

I can't presently see where/how this is set, so I can't do a PR to fix it. However, I will be happy to try with a hint. :wink: