Organizing grid elements within the popper component

I am struggling to align the labels of options in the AutoComplete component with their respective column headers in the popper component:

https://i.stack.imgur.com/0VMLe.png


        const CustomPopper = function (props: PopperProps) {
            const { children, ...rest } = props;
            return (
                <Popper {...rest} placement="bottom-start">
                    <Box sx={{
                        display: 'grid',
                        gridTemplateColumns: 'repeat(4, 1fr)',
                        gap: 1,
                        gridTemplateRows: 'auto',
                        gridTemplateAreas: `"date order name items"
                        "date order name items"`,
                    }}>

                        <Box sx={{ gridArea: 'date' }}><Typography>Created Date</Typography></Box>
                        <Box sx={{ gridArea: 'order' }}><Typography>Order</Typography></Box>
                        <Box sx={{ gridArea: 'name' }}><Typography>Name (email/phone)</Typography></Box>
                        <Box sx={{ gridArea: 'items' }}><Typography>Items</Typography></Box>
                    </Box>
                    {children}
                </Popper>
            );
        };

        <Autocomplete
                PopperComponent={CustomPopper}                   
                renderOption={(props, option: any) => {
                    return (
                        <li {...props} key={option.id} >
                            <Box sx={{ gridArea: 'items' }}>{convertToDateTime(option.createdtime).toFormat('d MMM HH:mm')}</Box>
                            <Box sx={{ gridArea: 'order' }}>{option.order}</Box>
                            <Box sx={{ gridArea: 'name' }}>{option.name} ({option.email}/{option.phone})</Box>
                            <Box sx={{ gridArea: 'date' }}>{option.itemlist}</Box>
                        </li>

                    );

                }      
            />
    

Answer №1

Transform every value into its own element and designate a specific max-width and min-width for each value to ensure proper alignment.

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

Steps for automatically toggling a button within a button-group when the page is loaded using jQuery in Bootstrap 3

Here is a button group setup: <div class="btn-group" data-toggle="buttons"> <label class="btn btn-default"> <input type="radio" name="environment" id="staging" value="staging" />Staging </label> <label class= ...

When an answer is provided in Inquirer.js, pressing Enter is causing the process to terminate

Currently, I am working on creating a Command Line Interface (CLI) using the NPM package called Inquirer. It has been a useful tool so far, but I have encountered an issue. The interface functions correctly in terms of posing questions to the user, but onc ...

Building basic objects in TypeScript

My current project involves utilizing an interface for vehicles. export interface Vehicle { IdNumber: number; isNew: boolean; contact: { firstName: string; lastName: string; cellPhoneNumber: number; ...

Module lazily loaded fails to load in Internet Explorer 11

Encountering an issue in my Angular 7 application where two modules, txxxxx module and configuration module, are lazy loaded from the App Routing Module. The problem arises when attempting to navigate to the configuration module, as it throws an error stat ...

Using Express and Node with MongoDB to handle POST requests in React

I am currently developing a program that utilizes React for the front-end, and an Express/Node API for the back-end to perform CRUD operations in a MongoDB database. While GET requests are functioning as expected, I am encountering issues with my POST requ ...

How can you use JQuery to assign a single function as an onClick handler for multiple radio buttons?

I have a custom function named handleOnClickRadio(i, j);, and multiple radio buttons with the IDs in the format of id="something-radio[i][j]". These radio buttons are all contained within a table labeled "bigtable". Is there a way to link the function han ...

Exploring BreakPoints using gridlisttiles

Can Grid List Tile components be configured to occupy the entire screen on small devices using sm={12} lg={6}, but only half of the screen on larger devices? If not, is there a way to adjust the grid list layout to display fewer tiles per row on smaller ...

The problem with MUI SwipeableDrawer not being recognized as a JSX.Element

Currently, I am implementing the SwipeableDrawer component in my project. However, an issue arises during the build process specifically related to the typings. I have made the effort to update both @types/react and @types/react-dom to version 18, but unf ...

Testing a React component using the `ua-parser-js` plugin with Jest and React Testing Library

I've developed a simple component that displays an image depending on the operating system you are using (in this case, iOS and Android). import { UAParser } from "ua-parser-js"; export const DownloadApp = ({ appleStoreUrl, playStoreUrl }: ...

Exploring the Power of useEffect in React Server Components

Upon user registration, they are directed to their account page. This is where I want to establish a profile connection in the users table on (Supabase). If this were a client-side scenario, the approach would be like this: const ProfilePage: FC<{ user ...

Leveraging IPFS to host a CSS stylesheet

I've been trying to load a css stylesheet using this link... I attempted adding the link tag to both the main and head tags. <link type="text/css" rel="stylesheet" href="https://ipfs.io/ipfs/Qmdun4VYeqRJtisjDxLoRMRj2aTY9sk ...

Preventing the Select component from constantly realigning

I am working with a Material UI Select component that allows users to select an entire category or specific items within the category. However, I have encountered an issue with the Select component realigning itself after a value is chosen. Is there a way ...

Refresh your webpage with new content and modified URLs without the need to reload using window.history.pushState

Hey everyone, I'm looking to incorporate window.history.pushState into my website, but I'm unsure of how to go about it... What I'm aiming for is to have a page dashboard.php and update the URL to dashboard.php?do=edit&who=me, while loa ...

The spread operator can be used within an if-else statement to condition

I am a beginner when it comes to React, and I'm facing a challenge while attempting to include an "if" statement within a spread component: Here is some example code: class CalenderView extends Component { parseActivitiesForCalendar = (activities) ...

Adjust the size of an element in response to changes in the size of

I've implemented a jQuery function to resize an element dynamically based on window size changes: $(window).resize(function() { topHeight = $("#top").height(); height = $(window).height() - 210; $("#container").height(height); $("#g").height( ...

What is the method for setting tabstops in XHTML?

Is there a way to create a tabstop in an xhtml webpage without using the "&nbsp;" method? I want to avoid putting a space between the ampersand and 'n'. Any suggestions? Edit: My initial post did not display the &nbsp;. I am looking for ...

Is it possible to bring in a `devDependency` into your code?

The Mobx DevTool's README instructs users to install it as a dev dependency, and then import it into their code. This approach raises concerns for me because devDependencies are typically reserved for tools used in the build process or managing end co ...

Having trouble accessing the latest version of the ReactJS single page application in Chrome

Our application is built on ReactJS and deployed using S3 and CloudFront. We are experiencing an issue where clients often need to perform a hard refresh of the web app to access the latest Single Page Application (SPA). In order to address this problem, ...

After extended periods of use, the website experiences frequent crashes

Currently, I am developing a website using a free provider (000webhost) and focusing on integrating a chat feature. To achieve this, I have implemented an interval every 500 milliseconds that reads a file to check for new messages. When a new message is de ...

Parsing Json data efficiently by utilizing nested loops

I have 2 different collections of JSON data, but I'm unsure of how to utilize JavaScript to parse the information. Data from API1 is stored in a variable named response1: [{"placeid":1,"place_name":"arora-square","city":"miami","state":"florida","c ...