Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion packages/react-aria-components/src/Table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1380,6 +1380,8 @@ export const ColumnResizer = forwardRef(function ColumnResizer(

let DOMProps = filterDOMProps(props, {global: true});

// Cursor overlay is used to style the cursor against the entire screen.
// Do not turn off pointer events or the cursor will no longer be styled.
return (
<dom.div
ref={objectRef}
Expand All @@ -1395,7 +1397,10 @@ export const ColumnResizer = forwardRef(function ColumnResizer(
{isResizing &&
isMouseDown &&
ReactDOM.createPortal(
<div style={{position: 'fixed', top: 0, left: 0, bottom: 0, right: 0, cursor}} />,
<div
style={{position: 'fixed', top: 0, left: 0, bottom: 0, right: 0, cursor}}
data-testid="cursor-overlay"
/>,
document.body
)}
</dom.div>
Expand Down
26 changes: 26 additions & 0 deletions packages/react-aria-components/test/Table.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import {
mockClickDefault,
pointerMap,
render,
screen,
setupIntersectionObserverMock,
triggerLongPress,
within
Expand Down Expand Up @@ -1837,6 +1838,31 @@ describe('Table', () => {
let resizers = getAllByTestId('resizer');
expect(resizers).toHaveLength(5);
});

describe('clicking directly on the resizer, no movement', () => {
installPointerEvent();
it('should end resize when clicking directly on the resizer, no movement', async () => {
let {getAllByTestId} = render(<ControlledResizableTable />);
act(() => {
setInteractionModality('pointer');
});
let resizer = getAllByTestId('resizer')[0];
fireEvent.pointerDown(resizer, {pointerType: 'mouse', pointerId: 1, pageX: 0, pageY: 30});
expect(resizer).toHaveAttribute('data-resizing', 'true');
// Fire events against the cursor overlay. It can't be pointer events none otherwise
// it will stop styling the cursor against the entire screen.
let cursorOverlay = screen.getByTestId('cursor-overlay');
fireEvent.pointerUp(cursorOverlay, {
pointerType: 'mouse',
pointerId: 1,
pageX: 0,
pageY: 30
});
fireEvent.click(cursorOverlay);
act(() => jest.runAllTimers());
expect(resizer).not.toHaveAttribute('data-resizing', 'true');
});
});
});

it('should support overriding table style', () => {
Expand Down
5 changes: 5 additions & 0 deletions packages/react-aria/src/table/useTableColumnResize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,11 @@ export function useTableColumnResize<T>(
) {
endResize(item);
}
},
onPressEnd: () => {
if (state.resizingColumn != null) {
endResize(item);
}
Comment on lines +297 to +301
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

One thing I noticed is that the resizing "divider" line now disappears as you drag the handle on mobile, doesn't seem to happen on main. Note that it doesn't cancel the resize event, it is only that the divider disappears

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

hmmm yeah, i am not 100% on this approach yet. But I hadn't found any bad behaviours yet, thanks for finding that. I'll revisit the approach again.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

lemme know if you need help investigating, I tested on Android.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

thanks, I'll let you know how i go tomorrow

}
});
let {visuallyHiddenProps} = useVisuallyHidden();
Expand Down
Loading