Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -1527,25 +1527,6 @@ export function TableGrid({
return
}

if ((e.metaKey || e.ctrlKey) && e.key === 'a') {
e.preventDefault()
const rws = rowsRef.current
const currentCols = columnsRef.current
if (rws.length > 0 && currentCols.length > 0) {
suppressFocusScrollRef.current = true
setEditingCell(null)
setRowSelection((prev) => (prev.kind === 'none' ? prev : ROW_SELECTION_NONE))
lastCheckboxRowRef.current = null
setSelectionAnchor({ rowIndex: 0, colIndex: 0 })
setSelectionFocus({
rowIndex: rws.length - 1,
colIndex: currentCols.length - 1,
})
setIsColumnSelection(false)
}
return
}

if ((e.metaKey || e.ctrlKey) && e.key === ' ') {
const a = selectionAnchorRef.current
if (!a || editingCellRef.current) return
Expand Down Expand Up @@ -2281,6 +2262,33 @@ export function TableGrid({
}
}, [])

useEffect(() => {
if (embedded) return
const handleSelectAll = (e: KeyboardEvent) => {
if (!(e.metaKey || e.ctrlKey) || e.key !== 'a') return
const target = e.target as HTMLElement
const tag = target.tagName
if (tag === 'INPUT' || tag === 'TEXTAREA' || tag === 'SELECT') return
if (target.isContentEditable) return
if (target.closest('[role="dialog"]')) return
if (!containerRef.current) return
const rws = rowsRef.current
const currentCols = columnsRef.current
if (rws.length > 0 && currentCols.length > 0) {
Comment thread
waleedlatif1 marked this conversation as resolved.
e.preventDefault()
suppressFocusScrollRef.current = true
setEditingCell(null)
setRowSelection((prev) => (prev.kind === 'none' ? prev : ROW_SELECTION_NONE))
lastCheckboxRowRef.current = null
setSelectionAnchor({ rowIndex: 0, colIndex: 0 })
setSelectionFocus({ rowIndex: rws.length - 1, colIndex: currentCols.length - 1 })
setIsColumnSelection(false)
}
}
document.addEventListener('keydown', handleSelectAll)
return () => document.removeEventListener('keydown', handleSelectAll)
}, [embedded])

const navigateAfterSave = useCallback((reason: SaveReason) => {
const anchor = selectionAnchorRef.current
if (!anchor) return
Expand Down
Loading