Skip to content

Create column menu #174

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

Open
wants to merge 44 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
be48281
Add column menu functionality to table headers
rembrandtreyes May 18, 2025
cfe0102
Enhance ColumnMenu with sorting functionality and refactor rendering …
rembrandtreyes May 18, 2025
51c5a41
Refactor ColumnMenu and integrate PortalContainer for improved rendering
rembrandtreyes May 18, 2025
2e1dcd7
Enhance HighTable CSS for improved sorting visuals
rembrandtreyes May 18, 2025
ecfb269
Refactor ColumnHeader and HighTable styles for improved usability
rembrandtreyes May 18, 2025
b17d387
Enhance ColumnMenu and ColumnMenuButton for improved accessibility an…
rembrandtreyes May 18, 2025
2231d6c
Improve ColumnMenuButton interaction and positioning
rembrandtreyes May 18, 2025
a907f22
Enhance ColumnHeader and ColumnMenu integration for improved function…
rembrandtreyes May 18, 2025
cfcdbef
Enhance ColumnMenu and ColumnMenuButton for improved focus management
rembrandtreyes May 18, 2025
d73acee
Refactor ColumnHeader and ColumnMenu for improved event handling and …
rembrandtreyes May 18, 2025
9059a97
Add tests for ColumnMenu and ColumnMenuButton components
rembrandtreyes May 18, 2025
8da548a
Update sortable prop handling in ColumnHeader for consistency
rembrandtreyes May 18, 2025
f397c61
Merge remote-tracking branch 'upstream/master' into rembrandtreyes/Co…
rembrandtreyes May 18, 2025
45d40fd
cleanup styles
rembrandtreyes May 18, 2025
9f77d7b
Add default props for ColumnHeader tests
rembrandtreyes May 19, 2025
56f76ac
Apply suggestions from code review
rembrandtreyes May 21, 2025
7c3c9be
Refactor HighTable to utilize usePortalContainer hook
rembrandtreyes May 21, 2025
6054ef0
Refactor ColumnHeader and ColumnMenu for improved state management an…
rembrandtreyes May 29, 2025
66da8cd
Enhance ColumnMenu functionality and styles
rembrandtreyes May 29, 2025
f27d220
Implement MenuItem and Overlay components in ColumnMenu
rembrandtreyes May 29, 2025
ff7f80b
Enhance ColumnMenu focus management and keyboard navigation
rembrandtreyes May 29, 2025
43b7d39
Enhance ColumnHeader toggle functionality
rembrandtreyes May 29, 2025
8906fd0
Enhance ColumnMenuButton accessibility and ColumnHeader functionality
rembrandtreyes May 29, 2025
eb3332b
Merge remote-tracking branch 'upstream/master' into rembrandtreyes/Co…
rembrandtreyes May 29, 2025
c11e9cc
Remove unused `buttonRef` prop from ColumnHeader and ColumnMenu compo…
rembrandtreyes May 29, 2025
b1c9dd9
Refactor ColumnHeader and ColumnMenu for improved functionality and a…
rembrandtreyes May 30, 2025
82498bd
Update HighTable styles for improved focus visibility
rembrandtreyes May 30, 2025
e01a906
Enhance accessibility and styles in ColumnHeader and HighTable
rembrandtreyes May 30, 2025
cec8566
Refactor ColumnMenu and TableHeader tests for improved clarity and fu…
rembrandtreyes May 30, 2025
3d5dc25
Update HighTable styles for sort arrow positioning
rembrandtreyes May 30, 2025
795da76
Refactor imports in HighTable and TableHeader components for cleaner …
rembrandtreyes May 30, 2025
b11258c
Refactor ColumnMenu to utilize useScrollLock hook for scroll management
rembrandtreyes May 30, 2025
62887fc
Implement focus management in ColumnMenu using useFocusManagement hook
rembrandtreyes May 30, 2025
3191a6e
Enhance ColumnHeader and ColumnMenuButton for improved accessibility …
rembrandtreyes May 30, 2025
5ec8d2f
Refactor ColumnHeader to utilize useColumnMenu hook for improved func…
rembrandtreyes May 30, 2025
1a65e7b
Update tests for ColumnHeader, ColumnMenuButton, and TableHeader for …
rembrandtreyes May 30, 2025
e2ad3ab
Refactor TableHeader tests to enhance column menu integration and acc…
rembrandtreyes May 30, 2025
701dc1f
Add onEscape handler to ColumnMenuButton for improved keyboard naviga…
rembrandtreyes May 30, 2025
fffbd0e
Enhance ColumnMenu tests for improved coverage and functionality
rembrandtreyes May 30, 2025
e6269a8
Refactor ColumnMenu tests for consistency and readability
rembrandtreyes May 30, 2025
26711c8
Refactor ColumnMenuButton to use button element for improved accessib…
rembrandtreyes Jun 12, 2025
57d6bc8
Merge remote-tracking branch 'upstream/master' into rembrandtreyes/Co…
rembrandtreyes Jun 12, 2025
59c1ee8
Update ColumnHeader and ColumnMenuButton to use button elements for i…
rembrandtreyes Jun 13, 2025
ea8981a
Update ColumnHeader and ColumnMenuButton tests for improved accuracy
rembrandtreyes Jun 13, 2025
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
6 changes: 4 additions & 2 deletions src/components/ColumnHeader/ColumnHeader.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ const defaultProps = {
columnIndex: 0,
ariaColIndex: 1,
ariaRowIndex: 1,
isColumnMenuOpen: false,
onToggleColumnMenu: vi.fn(),
}

describe('ColumnHeader', () => {
Expand Down Expand Up @@ -101,8 +103,8 @@ describe('ColumnHeader', () => {
// the width is set to undefined, and should then be measured,
// but the measurement (.offsetWidth) can only run in a browser,
// so its value is 0
// The fixed width is then adjusted to the minimum width: 10px
expect(header.style.maxWidth).toEqual('10px')
// The fixed width is then adjusted to the minimum width: 24px
expect(header.style.maxWidth).toEqual('24px')
Copy link
Author

Choose a reason for hiding this comment

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

Needed to bump this to 24px to now account for the sorting arrows and column menu button

expect(getOffsetWidth).toHaveBeenCalledTimes(1)
})

Expand Down
28 changes: 28 additions & 0 deletions src/components/ColumnHeader/ColumnHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,11 @@ import { flushSync } from 'react-dom'
import { Direction } from '../../helpers/sort.js'
import { getOffsetWidth } from '../../helpers/width.js'
import { useCellNavigation } from '../../hooks/useCellsNavigation.js'
import ColumnMenu from '../ColumnMenu/ColumnMenu.js'
import ColumnMenuButton from '../ColumnMenuButton/ColumnMenuButton.js'
import { useColumnStates } from '../../hooks/useColumnStates.js'
import ColumnResizer from '../ColumnResizer/ColumnResizer.js'
import { useColumnMenu } from '../../hooks/useColumnMenu.js'

interface Props {
columnIndex: number // index of the column in the dataframe (0-based)
Expand All @@ -22,7 +25,10 @@ interface Props {

export default function ColumnHeader({ columnIndex, columnName, dataReady, direction, onClick, orderByIndex, orderBySize, ariaColIndex, ariaRowIndex, className, children }: Props) {
const ref = useRef<HTMLTableCellElement>(null)
const buttonRef = useRef<HTMLButtonElement>(null)
const { tabIndex, navigateToCell } = useCellNavigation({ ref, ariaColIndex, ariaRowIndex })
const { isOpen, position, menuId, handleToggle, handleMenuClick } =
useColumnMenu(columnIndex, ref, navigateToCell)
Comment on lines +30 to +31
Copy link
Author

Choose a reason for hiding this comment

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

Add useColumnMenu hook to separate concerns

ColumnHeader was handling both column display and menu logic. This hook isolates menu state management, making the component easier to understand and test.

const handleClick = useCallback(() => {
navigateToCell()
onClick?.()
Expand Down Expand Up @@ -111,6 +117,7 @@ export default function ColumnHeader({ columnIndex, columnName, dataReady, direc
aria-description={description}
aria-rowindex={ariaRowIndex}
aria-colindex={ariaColIndex}
aria-expanded={isOpen}
tabIndex={tabIndex}
title={description}
onClick={handleClick}
Expand All @@ -120,13 +127,34 @@ export default function ColumnHeader({ columnIndex, columnName, dataReady, direc
data-fixed-width={dataFixedWidth}
>
{children}
{sortable &&
<ColumnMenuButton
ref={buttonRef}
onClick={handleMenuClick}
onEscape={navigateToCell}
tabIndex={tabIndex}
isExpanded={isOpen}
menuId={menuId}
aria-label={`Column menu for ${columnName}`}
/>
}
<ColumnResizer
forceWidth={forceColumnWidth}
autoResize={autoResize}
width={width}
tabIndex={tabIndex}
navigateToCell={navigateToCell}
/>
<ColumnMenu
columnName={columnName}
isOpen={isOpen}
position={position}
direction={direction}
sortable={sortable}
onClick={onClick}
columnIndex={columnIndex}
onToggle={handleToggle}
/>
</th>
)
}
Loading