Displaying the Inertia ProgressBar beneath the Appbar in React MUI

In my app.js file, I have initialized an inertia progress bar.

app.js

import React from "react";
import { render } from "react-dom";
import { createInertiaApp } from "@inertiajs/inertia-react";
import { InertiaProgress } from "@inertiajs/progress";

createInertiaApp({
  resolve: (name) => require(`./Pages/${name}`),
  setup({ el, App, props }) {
    render(<App {...props} />, el);
  },
});

InertiaProgress.init({    
    // The color of the progress bar.
    color: "red",

    // Whether the NProgress spinner will be shown.
    showSpinner: true,
});

However, the progress bar does not appear every time I render the appbar in the layout. It only occurs with the layout file because if I render without it, the progress bar works as usual.

Here is my Layout.tsx

import {
    Button,
    Container,
    ListItem,
    ListItemIcon,
    ListItemText,
    useTheme,
} from "@mui/material";
import React from "react";
import { styled, ThemeProvider } from "@mui/material/styles";
import CssBaseline from "@mui/material/CssBaseline";
import MuiDrawer from "@mui/material/Drawer";
import Box from "@mui/material/Box";
import MuiAppBar, { AppBarProps as MuiAppBarProps } from "@mui/material/AppBar";
import Toolbar from "@mui/material/Toolbar";
import List from "@mui/material/List";
import Typography from "@mui/material/Typography";
import Divider from "@mui/material/Divider";
import IconButton from "@mui/material/IconButton";
import MenuIcon from "@mui/icons-material/Menu";
import ChevronLeftIcon from "@mui/icons-material/ChevronLeft";

import { listItems } from "./ListItems";
import { usePage } from "@inertiajs/inertia-react";
import { Inertia } from "@inertiajs/inertia";
import route from "ziggy-js";
import FlashMessage from "./FlashMessage";
import { withStyles } from "@mui/styles";

const Layout = ({
    children,
    title,
}: {
    children: React.ReactNode;
    title: React.ReactNode;    
}) => {
    const theme = useTheme();

    const authUser: any = usePage().props.user;
    const drawerWidth: number = 240;

    interface AppBarProps extends MuiAppBarProps {
        open?: boolean;
    }
    
    const [open, setOpen] = React.useState(false);
    const toggleDrawer = () => {
        setOpen(!open);
    };

    const handleLogout = () => {
        if (confirm("are you sure want to logout?")) {
            Inertia.post(route("logout"));
        }
    };

    return (
        <ThemeProvider theme={theme}>
            <Box sx={{ display: "flex" }}>
                <CssBaseline />
                <AppBar position="absolute" open={open}>
                    <Toolbar
                        sx={{
                            pr: "24px", 
                        }}
                    >
                        <IconButton
                            edge="start"
                            color="inherit"
                            aria-label="open drawer"
                            onClick={toggleDrawer}
                            sx={{
                                marginRight: "36px",
                                ...(open && { display: "none" }),
                            }}
                        >
                            <MenuIcon />
                        </IconButton>
                        <Typography
                            component="h1"
                            variant="h6"
                            color="inherit"
                            noWrap
                            sx={{ flexGrow: 1, marginLeft: 2 }}
                        >
                            {title}
                        </Typography>
                        <Button
                            {...(authUser ? { display: "none" } : { sx: {} })}
                            variant="text"
                            color="inherit"
                            onClick={handleLogout}
                        >
                            Logout
                        </Button>
                    </Toolbar>
                </AppBar>
                <Drawer variant="permanent" open={open}>
                    <Toolbar
                        sx={{
                            display: "flex",
                            alignItems: "center",
                            justifyContent: "flex-end",
                            px: [1],
                        }}
                    >
                        <IconButton onClick={toggleDrawer}>
                            <ChevronLeftIcon />
                        </IconButton>
                    </Toolbar>
                    <Divider />
                    <List>{listItems}</List>
                </Drawer>
                <Box
                    component="main"                    
                    }}
                >
                    <Toolbar />
                    <FlashMessage />
                    <Container sx={{ marginTop: "50px" }}>{children}</Container>
                </Box>
            </Box>
        </ThemeProvider>
    );
};

export default Layout;

It seems that my progress bar appears under the appbar. Is there a solution to this problem?

Answer №1

To determine the zIndex of your AppBar, you can check the default value (which is typically 1100).

console.log(Theme.zIndex.appBar)

Next, in your CSS file, increase the zIndex of the progress bar by inserting this line:

#nprogress .bar {
    z-index: 1101!important;
}

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

The absence of a template or render function in a Vue.js 3 and Quasar 2 component has resulted in an

I am currently working on creating a dynamic component and passing a prop to it. However, I am encountering a warning message that says: Component is missing template or render function. Although the component is being rendered, I am still receiving the wa ...

Steps for incorporating a personalized action menu into a material table

Currently, I am trying to showcase a menu within the actions column on material-table. I came across a related post here: How show menu item in Material Table that provides a solution, but unfortunately I am unable to access the sandbox for testing and exp ...

What is the method for assigning a value to a Material UI text field?

Trying to create an autocomplete search feature using EsriGeocode and Material UI. The form includes Street name, City, State, and Zip code fields. Currently facing an issue where the Street name text field displays the entire address instead of just the s ...

Deactivate the Discord JS button

Looking to create a Discord bot in TypeScript and wanting to disable two buttons when one is clicked, but unsure how to accomplish this. This is my command with the two buttons (warn.ts): import { PermissionsBitField, ButtonBuilder, ActionRowB ...

Constantly showing blank white pages on my website specifically in Internet Explorer 11

I successfully developed a website using react, babel, webpack, and backend Django framework. Everything runs smoothly on Chrome, Safari, and Firefox, but when it comes to IE11, issues arise. Initially, the site functions properly, but after navigating thr ...

Is the text in bold format or not detectable in contenteditable mode?

I am currently working on developing a custom text editor using the built-in contenteditable feature in HTML. I am trying to figure out how to determine whether the selected text is bold or not within the editor. This is what my current setup looks like: ...

How to display the name of the parent object using JavaScript's prototypal inheritance

I've been delving into JavaScript prototypal inheritance and the prototype property, and I decided to create a fiddle to gain a deeper understanding. However, I'm struggling to comprehend why my example isn't functioning as expected. In the ...

The inclusion of <script> tag within the response received from an Ajax

Is there a way to update an element's innerHTML using Ajax.request that includes <script> tags? <div><script type="text/javascript">javascript</script></div> I want to update the content of a div with code from above wi ...

Utilizing AngularJS for handling HTTP responses

Hello, I am currently in the process of familiarizing myself with AngularJS for the second time. I have successfully created an http request without any issues. However, my question pertains to how I can retrieve the result of this request and store it in ...

Invoking a C# function inside a cshtml file

Having trouble calling a function in my CSHTML page. In the script of my CSHTML page : <script type="text/javascript" > //var sLoggedInUser = <%# GetSession_LoggedInIdUser() %>; $(document).ready(function () { ale ...

How can I implement a hover effect without triggering a click event?

My structure is pretty basic, here it is: .container { height: 100vh; width: 100%; pointer-events: none; } .click-layer { background-color: #ccc; position: absolute; top: 0; left: 0; right: 0; bottom: 0; pointer-events: auto; } .box { ...

"Error encountered when attempting to read a file from a dialog box using Electron due to

I am currently working on an electron program that requires reading a file in order to apply another program onto it. At this stage, my main goal is to successfully read and log the content of the file. Below is the code snippet I have implemented in a sc ...

Having difficulties transmitting numerical values through res.send() in express with node

Currently, I'm faced with a challenge in my express application on node.js as I attempt to retrieve the "imdb rating." movies.json [{ "id": "3962210", "order": [4.361276149749756, 1988], "fields": { "year": 2015, "title": "David and Goliath" ...

Developing a Quarantine Simulation Prototype Using JavaScript

I am in need of a method to determine if any passengers are not healthy. If "isHealthy" is false for any passenger, then the wagon should be quarantined. Additionally, there may be an issue with the join prototype where "isHealthy" is only triggered if a ...

Are you in need of a JavaScript data validation tool?

Trying to find a library that can validate input in a specific format, such as: { points: array of { x: positive and less than 20, y: positive and less than 15 } } Ideally, it should work on both server and client sides and either return a boolean or th ...

Exploring ways to seamlessly incorporate the Google Cloud Speech API into your website

As a beginner with the Google Cloud Platform, I am looking to incorporate the Google Speech API into my webpage using JavaScript. Despite researching documentation, I have been unable to find a solution. If anyone has knowledge on this topic, please help ...

What is the best way to eliminate "?" from the URL while transferring data through the link component in next.js?

One method I am utilizing to pass data through link components looks like this: <div> {data.map((myData) => ( <h2> <Link href={{ pathname: `/${myData.title}`, query: { ...

Encountering issues with JSON.stringify when trying to JSON-ify a freshly instantiated object (node.js

Hey there, I'm a beginner in the world of Node.js and JavaScript. If you spot any mistakes in my code below, please don't hesitate to point them out! Here's the scenario: I have two files - one that creates slave servers on different port ...

Tips for integrating a custom handler to the close icon in Material UI TextField component

In my Reactjs/Typescript project using Material UI, I have a search input component rendered with TextField. The built-in "x" icon clears the input value, but I want to create a custom handler for making an API call when the search value is deleted. I&apo ...

Is it possible to load Javascript using AJAX with jQuery?

So I have this JavaScript code that I insert into a webpage using the following: <script type="text/javascript" src="http://ext.nicovideo.jp/thumb_watch/sm13154955?w=640&h=395"></script> It basically places an object/embed code into the w ...