react-spectrum icon indicating copy to clipboard operation
react-spectrum copied to clipboard

Include colSpan values, while comparing the actual cell values with header columns count.

Open lakshmajee opened this issue 2 years ago โ€ข 7 comments

Provide a general summary of the issue here

Unable to make cell span over multiple columns headers

๐Ÿค” Expected Behavior?

Must pass the column length and cell count validation here, and render the table

๐Ÿ˜ฏ Current Behavior

Due to strict cell count (excluding colSpan) and column headers count, it is throwing an error

๐Ÿ’ Possible Solution

Include colSpan count while comparing with column headers vice-versa

๐Ÿ”ฆ Context

I have a requirement, where the UI needs to merge two columns into one in header, while maintaing two individula cells under same column header.

Plain HTML Example my usecase:

<!DOCTYPE html>
<html>
<head>
<style>
table, th, td {
  border: 1px solid black;
  border-collapse: collapse;
}
</style>
</head>
<body>

<h2>Cell that spans two columns</h2>
<p>To make a cell span more than one column, use the colspan attribute.</p>

<table style="width:100%">
  <tr>
    <th colspan="2">Name</th>
    <th>Age</th>
  </tr>
  <tr>
    <td>Jill</td>
    <td>Smith</td>
    <td>43</td>
  </tr>
  <tr>
    <td>Eve</td>
    <td>Jackson</td>
    <td>57</td>
  </tr>
</table>
</body>
</html>

It seems to be achievable at this stage.

๐Ÿ–ฅ๏ธ Steps to Reproduce

TODO

Version

@react-aria/[email protected]

What browsers are you seeing the problem on?

Firefox, Chrome

If other, please specify.

No response

What operating system are you using?

OSx

๐Ÿงข Your Company/Team

No response

๐Ÿ•ท Tracking Issue

No response

lakshmajee avatar Oct 31 '23 16:10 lakshmajee

We don't support this at the moment. Seems like a reasonable request, though may be difficult to implement due to the information needed in the columns as well as in the rows. We'll need to discuss API for it.

snowystinger avatar Oct 31 '23 22:10 snowystinger

Thank you for quick response. Thank you @snowystinger ๐Ÿ˜Š

lakshmajee avatar Nov 01 '23 03:11 lakshmajee

Support for this is pretty crucial for us @lightspeed ๐Ÿ˜„ We may be able to assist if necessary!

kysley avatar Nov 16 '23 14:11 kysley

That'd be great. We took a look at this today and noticed the description on the issue logged against us is different than the description in the linked issue on NextUI. Before starting, we'd like clarification about what is actually needed. Is it a cell that spans multiple columns or a column which spans multiple cells?

<td colspan...
vs
<th colspan...

We hope that it's the cell spanning multiple columns as the other one is more complicated we believe.

Things that will need some extra consideration while implementing:

  • TableKeyboardDelegate getKeyAbove/Below, columns in the collection are organized differently than rows in the collection
  • Do not worry about Spectrum's TableView component, it should continue to work as is
  • Resizing, scenario 1 may not be an issue, but definitely would be for scenario 2

snowystinger avatar Nov 16 '23 22:11 snowystinger

Thankfully we are looking for a cell that spans multiple columns. <td colspan.... We use this in conjunction with Expandable rows. We are using the entire react-aria suite for our new design system are now onto useTable for our table needs.

Here is a crude example in paint image

I managed to hack expandable rows together with #4758 as a guideline using UNSTABLE_useTreeGridState and looking at spectrum's TableViewWrapper. It doesn't play well with selecting rows, but that is expected of an undocumented alpha api ๐Ÿ™‚

kysley avatar Nov 17 '23 15:11 kysley

Great, I think we can start by creating this with a colspan prop on Cells. Would you like to get this started?

snowystinger avatar Nov 17 '23 21:11 snowystinger

I am also curious about this. Are there any workarounds I could apply to create expandable rows as @kysley suggested?

nonken avatar Jun 09 '24 19:06 nonken

Any news on this?

adneforslund avatar Jul 24 '24 10:07 adneforslund

@kysley 's paint picture explains exactly the behavior we would need also. Is there some progress on this issue yet? And I would be very grateful for any more explained workaround for this.

henkkasoft avatar Oct 30 '24 13:10 henkkasoft

so, this react spectrume still dont have colSpan ?

4RSIM3R avatar Nov 04 '24 06:11 4RSIM3R

Do you know what's the status?

Mdelacruzmelo avatar Jan 20 '25 11:01 Mdelacruzmelo

happy to see some progress on this one ๐Ÿ˜Š . Thank you @oyvinmar

lakshmajee avatar Mar 11 '25 07:03 lakshmajee