Skip to content

Commit

Permalink
Add support for experiemental features to make some strange use cases…
Browse files Browse the repository at this point in the history
… possible
  • Loading branch information
jassmith committed Dec 10, 2023
1 parent b943bfd commit ccf949b
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
12 changes: 8 additions & 4 deletions packages/core/src/internal/data-grid/data-grid-render.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1197,7 +1197,8 @@ function drawCells(
enqueue: EnqueueCallback,
renderStateProvider: RenderStateProvider,
getCellRenderer: GetCellRendererCallback,
overrideCursor: (cursor: React.CSSProperties["cursor"]) => void
overrideCursor: (cursor: React.CSSProperties["cursor"]) => void,
minimumCellWidth: number
): Rectangle[] | undefined {
let toDraw = damage?.length ?? Number.MAX_SAFE_INTEGER;
const frameTime = performance.now();
Expand Down Expand Up @@ -1441,7 +1442,7 @@ function drawCells(
}
}

if (cellWidth > 10 && !skipContents) {
if (cellWidth > minimumCellWidth && !skipContents) {
const cellFont = theme.baseFontFull;
if (cellFont !== font) {
ctx.font = cellFont;
Expand Down Expand Up @@ -2112,6 +2113,7 @@ export function drawGrid(arg: DrawGridArg, lastArg: DrawGridArg | undefined) {
renderStrategy,
bufferA,
bufferB,
minimumCellWidth,
} = arg;
let { damage } = arg;
if (width === 0 || height === 0) return;
Expand Down Expand Up @@ -2347,7 +2349,8 @@ export function drawGrid(arg: DrawGridArg, lastArg: DrawGridArg | undefined) {
enqueue,
renderStateProvider,
getCellRenderer,
overrideCursor
overrideCursor,
minimumCellWidth
);

const selectionCurrent = selection.current;
Expand Down Expand Up @@ -2564,7 +2567,8 @@ export function drawGrid(arg: DrawGridArg, lastArg: DrawGridArg | undefined) {
enqueue,
renderStateProvider,
getCellRenderer,
overrideCursor
overrideCursor,
minimumCellWidth
);

drawBlanks(
Expand Down
7 changes: 6 additions & 1 deletion packages/core/src/internal/data-grid/data-grid.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,8 @@ export interface DataGridProps {
*/
readonly experimental:
| {
readonly disableAccessibilityTree?: boolean;
readonly disableMinimumCellWidth?: boolean;
readonly paddingRight?: number;
readonly paddingBottom?: number;
readonly enableFirefoxRescaling?: boolean;
Expand Down Expand Up @@ -713,6 +715,7 @@ const DataGrid: React.ForwardRefRenderFunction<DataGridRef, DataGridProps> = (p,

const renderStateProvider = React.useMemo(() => new RenderStateProvider(), []);

const minimumCellWidth = experimental?.disableMinimumCellWidth === true ? 1 : 10;
const lastArgsRef = React.useRef<DrawGridArg>();
const draw = React.useCallback(() => {
const canvas = ref.current;
Expand Down Expand Up @@ -777,6 +780,7 @@ const DataGrid: React.ForwardRefRenderFunction<DataGridRef, DataGridProps> = (p,
renderStateProvider,
renderStrategy: experimental?.renderStrategy ?? (browserIsSafari.value ? "double-buffer" : "single-buffer"),
getCellRenderer,
minimumCellWidth,
};

// This confusing bit of code due to some poor design. Long story short, the damage property is only used
Expand Down Expand Up @@ -843,6 +847,7 @@ const DataGrid: React.ForwardRefRenderFunction<DataGridRef, DataGridProps> = (p,
lastWasTouch,
renderStateProvider,
getCellRenderer,
minimumCellWidth,
]);

const lastDrawRef = React.useRef(draw);
Expand Down Expand Up @@ -1626,7 +1631,7 @@ const DataGrid: React.ForwardRefRenderFunction<DataGridRef, DataGridProps> = (p,

const accessibilityTree = useDebouncedMemo(
() => {
if (width < 50) return null;
if (width < 50 || experimental?.disableAccessibilityTree === true) return null;
let effectiveCols = getEffectiveColumns(mappedColumns, cellXOffset, width, dragAndDropState, translateX);
const colOffset = firstColAccessible ? 0 : -1;
if (!firstColAccessible && effectiveCols[0]?.sourceIndex === 0) {
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/internal/data-grid/draw-grid-arg.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,4 +76,5 @@ export interface DrawGridArg {
readonly enqueue: EnqueueCallback;
readonly renderStateProvider: RenderStateProvider;
readonly getCellRenderer: GetCellRendererCallback;
readonly minimumCellWidth: number;
}

0 comments on commit ccf949b

Please sign in to comment.