-
Notifications
You must be signed in to change notification settings - Fork 1.2k
TableView column resizing #2555
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Labels
Comments
Does anyone have any specific plans to implement this? If not, our team needs it and has bandwidth to do it; I just don't want to duplicate work. |
@chuckdries yes we have a team in the exploration phase here - I'll reach out to you privately with details |
Accessibility Proposal
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
🙋 Feature Request
Users have requested the ability to resize columns in TableView by dragging a divider between them. This is a common feature in many table components, and allows users to configure tables to suit their needs. Since this is a large project, this ticket is for initial API and behavior, including pointer support. Subsequent tickets will address keyboard and screen reader accessibility.
💁 API
The
Column
component should gain the following API:🤔 Expected Behavior
allowsResizing
prop must be set to enable the user to resize a column.onResize
prop on a column will be called when the user resizes a column. It receives the new width as an argument. Widths are represented in pixels.width
prop is set on a column, the width is controlled. This means the width won’t update unless thewidth
prop changes (e.g. as a result of setting state in theonResize
callback). This is useful for storing the column widths in an external state store.defaultWidth
prop is set, the width is uncontrolled. The state is stored internally to theTableView
.minWidth
andmaxWidth
props constrain the amount a user can resize a column. If unset, there is a default minimum width for a column, and no maximum width (??).col-resize
cursor should be shown. It should also be shown at all times while dragging, even when the cursor is not directly over the divider.Open questions
3 options:
Implementation
useTableColumnResizeState
hook should be created in@react-stately/table
. This will encapsulate the state management and logic for table column resizing.TableLayout
into this hook to make it reusable. This is responsible for determining the widths of columns without explicitly defined widths, dividing the available space and taking constraints such as minimum and maximum widths into account.useTableColumnResizeHandle
hook should be created in@react-aria/table
to encapsulate the dragging behavior.useMove
hook, updating the resize state.💻 Examples
Uncontrolled (static)
This example shows how you could have uncontrolled widths using the
defaultWidth
prop. The state for the actual width is stored internally to the component. Note that thedefaultWidth
is not required for a column to be resizable. The initial width will be automatically computed if not provided.Controlled (dynamic)
This example shows how you could have the widths be controlled, i.e. stored in external state. This could be useful to allow persisting the widths to a server, local storage, etc.
This could potentially be made slightly simpler using the
useListData
hook, and potentially a new method to update an existing item, but that is out of scope for this ticket.🧢 Your Company/Team
RSP
The text was updated successfully, but these errors were encountered: