palantir/blueprint

Table header does not render correctly in animated components, like dialog boxes

Open

#918 aperta il 30 mar 2017

Vedi su GitHub
 (2 commenti) (0 reazioni) (0 assegnatari)TypeScript (2167 fork)batch import
P2Package: tableType: bughelp wanted

Metriche repository

Star
 (20.263 star)
Metriche merge PR
 (Merge medio 43g 10h) (27 PR mergiate in 30 g)

Descrizione

Bug report

  • Package version(s): @blueprintjs/table 1.10.0
  • Browser and OS versions: Chrome 57.0.2987.98 (64-bit) on macOS 10.12.4

Steps to reproduce

Using the following code inside a component that is inserted in to a Blueprint dialog, the table header is misaligned:

	render() {
		return (
			<Table numRows={this.state.data.length}>
				<Column name="Date" renderCell={this.renderDates} />
				<Column name="Project ID" renderCell={this.renderProjects} />
				<Column name="Task ID" renderCell={this.renderTasks} />
				<Column name="Hours" renderCell={this.renderHours} />
				<Column name="Notes" renderCell={this.renderNotes} />
			</Table>
		);
	}

Actual behavior

The misaligned header: image1

Expected behavior

The aligned header: image2

Source of issue

It appears that the source of the issue is in syncMenuWidth() in table.tsx. It occurs because the dialog box is going through a CSS animated transition, the rowHeaderElement gets resized temporarily and during said resize, the menuElement grabs the width from the rowHeaderElement.

(Somewhat) workaround

It is possible to add a transitionend event handler on document in the componentDidMount() handler that calls this.setState() to force a redraw, but that doesn't completely fix the issue as the header is still slightly misaligned afterward. It also causes a shift of the header after it is visible. It would be much better to have the header be set correctly once at the beginning.

Guida contributor