Collapsible Rows in Material-UI Table seamlessly integrated with regular rows

While using material-ui v4, I encountered an issue where my collapsible row columns are not aligning properly with my regular columns. Below is a photo and the code snippet for reference. As you can see in the image, when I expand the Frozen Yogurt row, the columns do not line up with the headings (dessert, calories, fat, carbs, protein). Is there a way to make the columns in the collapsible row align with the table headings? Additionally, I would like them to remain aligned even when the screen size changes.

Click here for the image of the issue

import React from "react";
import PropTypes from "prop-types";
import { makeStyles } from "@material-ui/core/styles";...
 ...
 ...
    					</Table>
    				</Box>
    			</Collapse>
    		</TableCell>
    	</TableRow>
    </React.Fragment>
  );
}

Row.propTypes = {
	row: PropTypes.shape({...}).isRequired
};

const rows = [
	createData("Frozen yoghurt", 159, 6.0, 24, 4.0, 3.99),
	createData("Ice cream sandwich", 237, 9.0, 37, 4.3, 4.99),
	createData("Eclair", 262, 16.0, 24, 6.0, 3.79),
	createData("Cupcake", 305, 3.7, 67, 4.3, 2.5),
	createData("Gingerbread", 356, 16.0, 49, 3.9, 1.5)
];

export default function CollapsibleTable() {
	return (
		<TableContainer component={Paper}>
			... 
			(remaining code remains the same as provided)
            ...  
			
					

Answer №1

To solve the issue, you can specify a negative margin. I have demonstrated adding it as an inline style, but you can also include it within an object using makeStyles

<IconButton
  style={{ marginLeft: "-24px" }}
  aria-label="expand row"
  onClick={() => setOpen(!open)}>
  {open ? <KeyboardArrowUpIcon /> : <KeyboardArrowDownIcon />}
</IconButton>;

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

What steps do I need to take to design a menu?

I need assistance in organizing my menu with submenus. The code I currently have successfully retrieves all the submenus, but I would like to categorize them accordingly: For instance: Main Menu - Submenu 1, Submenu 2, Submenu 3 How can I go about categ ...

Adding the 'None' option to a select menu using Material UI in a React application can

I am currently working on implementing Material UI React Storybook. To avoid hardcoding select options, I have mapped them out. However, I am struggling to add a "None" option similar to the Material UI select component. When "None" is selected, nothing sh ...

Prevent the MUI Swipeable edge drawer from opening when touched temporarily

After implementing the MUI React drawer with a swipeable edge, I noticed two different actions on mobile. Touching the edge temporarily opens the drawer, while swiping up opens it permanently. However, I want to disable the temporary opening on touch becau ...

Keycloak does not support using the updateToken() function within an asynchronous function

In our development of a Spring application with React/Redux frontend, we faced an issue with Keycloak authentication service. The problem arose when the access token expired and caused unexpected behavior in our restMiddleware setup. Here is a simplified v ...

The current state is combining with the new state to create a duplicated rendering

I'm struggling to understand why my component is rendering both the previous prop and the new prop instead of just the difference. For instance, it currently outputs: [[1, 2, 3, 4, 5]] [[6, 7, 8, 9, 10]] [[1, 2, 3, 4, 5]] [[6, 7, 8, 9, 10]] [[16, 5 ...

Playfully imitating cross-fetch

I am currently running tests on a Next/React project using Jest with Node. I have also implemented cross-fetch in my project. However, I encountered an issue when trying to mock cross-fetch for a specific component: import crossFetch from 'cross-fetc ...

Struggling to remove a column from my Mysql database table

I've exhausted all my options, but I still can't seem to delete data from my MySQL table using axios.delete with ProjectId (table ids). Below is the code snippet where I define my function and pass it through props: import React from "react"; im ...

Foundation Unveil Modal hidden from view

I'm currently integrating modals using Foundation 5 in a Rails application. The issue I'm facing is that the modal only works when the page is not scrolled down. If you scroll to the bottom of the page and try to activate the modal by clicking ...

Tips on maintaining the original text hues that were established using setForeground() when a QTableWidgetItem is picked

Issue at Hand: Currently, when the first row is selected as shown in Figure 2 below, all text colors are changed to black, instead of maintaining their original style displayed in Figure 1. Is there a way to retain the original colors when a row is selec ...

Improper layout on laptop screens with smaller dimensions

The design looks great on a 24-inch laptop, but on an 11-inch screen, the layout becomes distorted. The right column shifts down... Check out the layout here Below is my code: <div class="row" style="margin-left: 325px;"> <div class="span12 ...

Next.js is constantly encountering an issue where it throws an error stating "params

I've managed to establish a successful connection between my custom server using Node.js and Express.js with Next.js. The issue I'm facing is when trying to fetch a specific car by its id upon clicking it among other cars, as I keep encountering ...

Troubleshooting problem with toggling menu in ReactJS using Material UI

I've been working on a feature that involves toggling the open state of a menu using both a button and menu items. However, I'm facing an issue where the menu expands when clicked but doesn't close upon a second click. class Topbar extends R ...

What is the best way to send variables using fetch in next.js?

I am currently working on setting up a login page. I am attempting to send some variables to my API, but I am encountering a fetch error. Here are the snippets of code that I am using: const fetchData = async () => { const req = await fetch(' ...

Plotting Data Points with Tags in React Native

After doing some research, I came across a few React Native packages that offer scatter plots such as react-native-scatter-chart, react-native-chart-kit, and react-native-chartjs. However, I am interested in finding something more customizable. I'm s ...

The CSS code for ::before is not functioning properly

Trying to enhance the style in Ionic2, I have a message box: I am attempting to integrate this image into it: To create a seamless look with the message box. Facing an issue where the image is not being applied at all. The CSS code I am using specifies ...

Ways to alter the default background color in material-ui

I am currently working on creating a dashboard for my company and I am looking to modify the default styles of some material components. Specifically, I want to change the background color of the Paper component without having to add my style to each ind ...

Update the Azure Variable group within the Azure Pipeline to include configurations for the .NET app settings and node JSON files

I have set up variable groups in the Azure library and linked them to an Azure pipeline. How can I initialize the xxx.json file? I also need to update the variables within the xxx.json file for both a React and .NET project. After adding variables to the ...

Exploring ways to store session data in Next.js 13 with Supabase for seamless persistence

Encountering an issue with next-auth. Upon logging in, the result shows ({error: 'SessionRequired', status: 200, ok: true, url: null}), despite having an active session. The console also displays this error message, which I believe may be related ...

The SharePoint 2010 standard model dialogs seamlessly blend transparent printing with the background content

When using Sharepoint 2010, each list item you edit will open in a new modal dialog box by default. This dialog box appears as a new div with the class of ms-dlgContent. It also creates a div with the class of ms-dlgOverlay which acts as a grey overlay di ...

Fade out a dynamically loaded content block using jQuery

I am currently developing a small app and encountering issues with deleting (fading out) dynamically loaded div elements using jQuery. The problem occurs when adding a new content box. If the page is reloaded and the content box is rendered normally (from ...