Skip to content

Upgrade Student Table to react-table v8 #7826

Merged
david-yz-liu merged 17 commits intoMarkUsProject:masterfrom
lizzie-liu:upgrade-student-table
Mar 5, 2026
Merged

Upgrade Student Table to react-table v8 #7826
david-yz-liu merged 17 commits intoMarkUsProject:masterfrom
lizzie-liu:upgrade-student-table

Conversation

@lizzie-liu
Copy link
Contributor

@lizzie-liu lizzie-liu commented Feb 12, 2026

Proposed Changes

  • Migrated the Student Table to use @tanstack/react-table v8
  • Updated the base Table component to support row selection using TanStack’s built-in row selection API
  • Updated the base Table component to render a loading spinner at the top of the table when it's in loading state
    • Loading spinner appears at top of table when loading={true} and rows exist (see Screenshot 1)
    • Retained original behavior of showing spinner in empty table state

Notes:
I had to manually implement the loading spinner UI since TanStack Table v8 is a headless library with no built-in UI components, unlike the old table which had built-in loading overlay rendering in its core table implementation.

The original table displayed the loading spinner overlayed on top of the last few rows of the table, but I placed the loading spinner at the top instead since:

  • .rt-tbody has overflow-y: scroll and flex-direction: column
  • When adding the spinner after the row elements in the normal document flow, it gets pushed below the visible scroll area and isn't visible to users
  • To overlay it on the bottom rows, it would require absolute positioning with inline styles

I did implement a version with the original bottom-overlay positioning (see Screenshot 2), but it required inline CSS for absolute positioning, which I think would be harder to maintain?

Would it be better to keep the original bottom-overlay behavior despite the inline styling, or is the top placement (current implementation) a better option?

Details

Screenshot 1
image

Screenshot 2
image

Associated documentation repository pull request (if applicable)

Type of Change

(Write an X or a brief description next to the type or types that best describe your changes.)

Type Applies?
🚨 Breaking change (fix or feature that would cause existing functionality to change)
New feature (non-breaking change that adds functionality)
🐛 Bug fix (non-breaking change that fixes an issue)
🎨 User interface change (change to user interface; provide screenshots)
♻️ Refactoring (internal change to codebase, without changing functionality) X
🚦 Test update (change that only adds or modifies tests)
📦 Dependency update (change that updates a dependency)
🔧 Internal (change that only affects developers or continuous integration)

Checklist

(Complete each of the following items for your pull request. Indicate that you have completed an item by changing the [ ] into a [x] in the raw text, or by clicking on the checkbox in the rendered description on GitHub.)

Before opening your pull request:

  • I have performed a self-review of my changes.
    • Check that all changed files included in this pull request are intentional changes.
    • Check that all changes are relevant to the purpose of this pull request, as described above.
  • I have added tests for my changes, if applicable.
    • This is required for all bug fixes and new features.
  • I have updated the project documentation, if applicable.
    • This is required for new features.
  • If this is my first contribution, I have added myself to the list of contributors.

After opening your pull request:

  • I have updated the project Changelog (this is required for all changes).
  • I have verified that the pre-commit.ci checks have passed.
  • I have verified that the CI tests have passed.
  • I have reviewed the test coverage changes reported by Coveralls.
  • I have requested a review from a project maintainer.

Questions and Comments

(Include any questions or comments you have regarding your changes.)

return data.sections[value] || "";
},
enableColumnFilter: Boolean(data.sections),
filterFn: (row, columnId, filterValue) => {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The filtering for both "Section" and "Active?" columns is not working. As a starting point, the filter dropdowns aren't showing the correct labels

if (isNaN(filterValue)) {
return true;
}
return row.getValue(columnId) === filterValue;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This filtering isn't working either (I suspect a type mismatch)

},
});

export const selectionColumn = columnHelper.display({
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This column should not be resizable

getCheckboxProps: PropTypes.func.isRequired,
};

let StudentTable = withSelection(RawStudentTable);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can rename the existing RawStudentTable into StudentTable. (The only reason we had both before was because of this withSelection call, but now that's no longer needed.)

</div>
)}
<div className="rt-tbody" style={{minWidth: table.getCenterTotalSize()}}>
{loading && table.getRowModel().rows.length > 0 && <LoadingSpinner />}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As we discussed at our meeting, let's leave the loading spinner at the bottom for now; I think you can revert the related changes here.

@lizzie-liu lizzie-liu marked this pull request as ready for review March 1, 2026 16:06
@coveralls
Copy link
Collaborator

coveralls commented Mar 1, 2026

Pull Request Test Coverage Report for Build 22721551632

Details

  • 37 of 39 (94.87%) changed or added relevant lines in 3 files are covered.
  • 2 unchanged lines in 2 files lost coverage.
  • Overall coverage decreased (-0.008%) to 91.669%

Changes Missing Coverage Covered Lines Changed/Added Lines %
app/javascript/Components/student_table.jsx 18 20 90.0%
Files with Coverage Reduction New Missed Lines %
app/javascript/Components/student_table.jsx 1 86.25%
app/javascript/Components/Helpers/table_helpers.jsx 1 27.66%
Totals Coverage Status
Change from base Build 22679544648: -0.008%
Covered Lines: 45020
Relevant Lines: 48298

💛 - Coveralls

@lizzie-liu lizzie-liu requested a review from david-yz-liu March 1, 2026 19:48
Copy link
Collaborator

@david-yz-liu david-yz-liu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work, @lizzie-liu!

@david-yz-liu david-yz-liu merged commit fb282e0 into MarkUsProject:master Mar 5, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants