Components in a Polymer app-layout sliding behind each other

When using the polymer app-layout, I encountered an issue where the menu slides behind my buttons and leaflet map. Even when scrolling down, the content remains on top of the header. I attempted to resolve this by adjusting the z-index, but so far have been unsuccessful. This project utilizes TypeScript and Polymer 3.

nav-bar.ts

import { PolymerElement, html } from "@polymer/polymer";
import "@polymer/iron-icons/iron-icons.js";
import "@polymer/app-layout/app-drawer-layout/app-drawer-layout.js";
import "@polymer/app-layout/app-drawer/app-drawer.js";
import "@polymer/app-layout/app-scroll-effects/app-scroll-effects.js";
import "@polymer/app-layout/app-header/app-header.js";
import "@polymer/app-layout/app-header-layout/app-header-layout.js";
import "@polymer/app-layout/app-toolbar/app-toolbar.js";
import "@vaadin/vaadin-button/vaadin-button.js";
import '@polymer/paper-icon-button/paper-icon-button.js';
import '@polymer/paper-checkbox/paper-checkbox.js';
import './my-app.js'

class NavBar extends PolymerElement {
static get template() {
return html`
<style>
    app-header {
      color: #fff;
      background-color: #C62828;
      --app-header-background-front-layer: {
        background-position: 50% 10%;
      };
    }
    [main-title] {
      font-size: 2em;
    }
    </style>
    <app-drawer-layout>
      <app-drawer swipe-open slot="drawer">
        <section>
          <h2>app-header </h2>     
          <h2>app-header </h2>
        </section>
      </app-drawer>
      <app-header-layout>
        <app-header fixed="true"  shadow="true" condenses="true"
      slot="header">
          <app-toolbar>
            <paper-icon-button  drawer-toggle>,
            <iron-icon icon="search"></iron-icon></paper-icon-button>
            <div condensed-title>Test</div>
          </app-toolbar>
          <app-toolbar></app-toolbar>
          <app-toolbar>
            <div main-title spacer>Test</div>
          </app-toolbar>
        </app-header>
      </app-header-layout>
    </app-drawer-layout>
    <my-app appTitle="my app"></my-app>
    `;
}}
customElements.define("nav-bar", NavBar);

Even if I copy-paste one of their demos from webcomponents.org app-layout, the problem persists. I also tried including this in my index.html with the same outcome:

<nav-bar></nav-bar> 
<my-app></my-app>

This is how it currently appears:
scrolling - the button "Test" belongs to my-app rather than being a part of the header.
with the menu open - another example showing leaflet map and buttons.
Is there any way to modify this behavior so that the header and menu always remain as the topmost layer?

Answer №1

In my opinion, separating the toolbar from the drawer can help achieve the desired functionality.

For a practical demonstration, you can check out this example: DEMO

import { PolymerElement } from "@polymer/polymer";
import {html} from '@polymer/polymer/lib/utils/html-tag.js';

import "@polymer/iron-icon/iron-icon.js";
import '@polymer/iron-icons/iron-icons.js';

import "@polymer/app-layout/app-drawer-layout/app-drawer-layout.js";
import "@polymer/app-layout/app-drawer/app-drawer.js";
import "@polymer/app-layout/app-scroll-effects/app-scroll-effects.js";
import "@polymer/app-layout/app-header/app-header.js";
import "@polymer/app-layout/app-header-layout/app-header-layout.js";
import "@polymer/app-layout/app-toolbar/app-toolbar.js";
import "@vaadin/vaadin-button/vaadin-button.js";
import '@polymer/paper-icon-button/paper-icon-button.js';
import '@polymer/paper-checkbox/paper-checkbox.js';
import './my-app.js';
class NavBar extends PolymerElement {
static get properties() { return {
  drawerOpened:{type:Boolean}
}}
static get template() {
return html`
<style>
    host:{
      display:block;
      background-color:red;
    }
    app-header {
      color: '#fff';
      background-color: grey;

    }
    [main-title] {
      font-size: 2em;
    }
    app-toolbar.tb1 { background-color: yellow;}
    app-toolbar.tb2 { background-color: green;}
    app-toolbar.tb3 { background-color: brown;}
    paper-icon-button { color: white }
    app-drawer > * { padding: 20px;}
    </style>

        <app-header fixed="true"  shadow="true" condenses="true"
      slot="header">
          <app-toolbar spacer class='tb1'>
            <paper-icon-button  icon='menu' on-tap='drawerToggle'></paper-icon-button>
            <div condensed-title> Tool Bar-1</div>
          </app-toolbar>
          <app-toolbar class='tb2'></app-toolbar>
          <app-toolbar class='tb3'>
            <div main-title spacer>Main Title</div>
          </app-toolbar>
        </app-header>
      <app-drawer-layout>
      <app-drawer opened="{{drawerOpened}}" swipe-open slot="drawer">

          <h1> Side Menu</h1>
          <h2> App-header </h2>     
          <h2> App-header </h2>

      </app-drawer>
      </app-drawer-layout>
    <my-app appTitle="my app"></my-app>
    `;}

    drawerToggle(){
       this.drawerOpened = !this.drawerOpened;
    }

}
customElements.define("nav-bar", NavBar);

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Alert: Attempting to invoke the setState method on an unmounted component

While running unit tests with Jest, I encountered a warning when attempting to change the setState input value. The warning message says: "Can't call setState on a component that is not yet mounted. This is a no-op, but it might indicate a bug in you ...

Ways to create more space between text and images with Bootstrap 5

Is there a way to adjust the spacing between descriptive text and an image on a webpage? I've tried fixing it, but it didn't work. How can I ensure that my text is properly separated from the image? Thank you. <!DOCTYPE html> <html lang ...

Is it possible to utilize Sequelize model methods to articulate the given SQL query effectively?

I've been spending hours trying to convert the following SQL query into a Sequelize model method like findOne() - SELECT * FROM "Tariffs" WHERE "tariffType" = 'DateRange' AND (('${body.startDate}' BETWEEN "startDate" AND "endDate" ...

Display video exclusively on desktop using Next.js: useEffect is unable to update a React state on a component that is unmounted

I am facing an issue with my Next.js website where I want to render a video only on desktop and not on mobile. To achieve this, I created a custom React hook to track the window size using the isDesktop state variable. While everything seems to be working ...

Setting a specific time zone as the default in Flatpickr, rather than relying on the system's time zone, can be

Flatpickr relies on the Date object internally, which defaults to using the local time of the computer. I am currently using Flatpickr version 4.6.6 Is there a method to specify a specific time zone for flatpickr? ...

Browsing through Chrome and Firefox using HTML interface

Hey everyone, I'm facing a few issues with displaying HTML and could use some help: Currently, I have a background image set for the <body></body> element of my HTML page using the following CSS: body { background: url('XYZ.j ...

The final condition of the ternary operator fails to render if the specified condition is satisfied

Having trouble identifying the issue with this ternary statement. The last element (blurredscreen) is not appearing when authStatus !== "authenticated". return ( <> <div key={"key-" + id}> {isO ...

Event triggered by changing input on jQuery mobile slider

I'm currently working with the jQuery mobile slider input feature. On my webpage, I have multiple sliders implemented, and I've noticed that the "change" event is triggered frequently, rather than just when the actual input value changes. Here&ap ...

What is the best way to center the circle and arrow within the border using CSS?

When the "hit" button is clicked, the arrow should move to touch the circle and change the color of the circle. My goal is to position the circle on the left side and center, with the arrow on the right side and center. section { border: 3px solid bl ...

Leveraging the power of AJAX and JSON to showcase dynamic HTML content pulled from PHP

I'm working on retrieving data from my PHP file, and it contains information in the columns Email, FirstName, LastName, and State. $query = 'SELECT * FROM users WHERE LOWER(Email) = :email'; $stmt = $dbh->prepare($query); $stmt->bindV ...

JavaScript function to add or remove a class upon clicking

Currently experiencing an issue with my accordion functionality. I have successfully implemented code that allows for toggling one heading open at a time, but I am struggling to add an open/close image beside each heading. At the moment, when a heading is ...

Collaborating an Ember JS application with a React host through microfrontend integration

While attempting to integrate various frontend technologies within a React host using microfrontends, I successfully connected React, Vue, and VanillaJS applications to the host. However, I've hit a roadblock when it comes to incorporating Ember JS. U ...

What is the process for importing a JavaScript export file created from the webpack.config file?

Issue at Hand In the process of testing APIs, I encountered a dilemma in setting up either the DEV or Production environment. This involved configuring API endpoints for local testing and preparing them for production use. To achieve this, I utilized NOD ...

"Exploring the advancements in inner calls and the deprecation of forkJoin

Here is the code snippet I am currently working with: ngOnInit(): void { this.issueService.getIssues().pipe( switchMap(issues => { this.issuesList = issues; const observables = this.issuesList.map(issue => this.issueService.getChild ...

Can transitions be applied to links in this manner?

Having an issue with ajax requests, I am currently resorting to using JavaScript linking. This is how I normally link: window.location.href = ('file:///android_asset/www/custom/kontakty.html'); I am curious if it's possible to add a transi ...

React and Express: Encounter a proxy error when trying to proxy the request for /total from localhost_errors

This question is a continuation of my previous inquiry on React.js: Axois Post stay on pending(but i am getting data) Below is the content of my package.json file { "name": "my-app", "version": "0.1.0", "private": true, "dependencies": { "ax ...

What is the correct way for Typescript to expect me to format a "number"?

Is it acceptable to use a number in the width attribute of a Quasar drawer component? <q-drawer v-model="leftDrawer" side="left" bordered content-class="bg-grey-2" width=100> </q-drawer> I've been using the w ...

The server-side PHP script may not always successfully respond to an Ajax call from the client

Whenever I try to access my index.html site, there are times when the Ajax request is made to call the PHP on the server in order to display the dynamic content. But for some reason, it only works intermittently when I manually refresh the page using the a ...

Converting uploaded file data into JSON format using JavaScript

I am currently loading a JSON data file, however the data is being read as a string. I am attempting to convert this string into a JSON object using JSON.parse, but it still remains as a string. Here is the content of the JSON file: { "annotations": ...

Exporting a class from an index.ts file may result in a problem where the injected constructor is

Utilizing an index.ts file to manage exports, following the guidelines outlined in the Angular 2 style guide (https://github.com/mgechev/angular2-style-guide/blob/master/old/README.md#directory-structure), has been successful throughout my application deve ...