Skip to content

Commit 69e8cdd

Browse files
authored
fix: keep active cell selection in first column from going offscreen (#1823)
- change cell input to not go off edge - makes activeCellSelectionBorderWidth a theme variable, so it can be shared with js and css - change canvas active cell outline to only stick to edge if at left edge of screen, not in any column - re-style active cell input to match latest input variables - change outline of input to use selection border color active cell input in the first column fully onscreen, before: ![image](https://github.com/deephaven/web-client-ui/assets/1576283/468083d3-8ee7-4624-94c2-191cc7a541d9) after: ![image](https://github.com/deephaven/web-client-ui/assets/1576283/53d0372a-225d-44b7-8bdc-b08cd9a1cef1) cell selected but not active, and partially scrolled offscreen, before: ![image](https://github.com/deephaven/web-client-ui/assets/1576283/6be27c0e-763d-482d-8cee-1af545fdd15c) after: ![image](https://github.com/deephaven/web-client-ui/assets/1576283/ed556685-fcfa-4069-bc98-12ec9d4a6d92)
1 parent 8d95212 commit 69e8cdd

7 files changed

Lines changed: 40 additions & 18 deletions

File tree

packages/grid/src/Grid.tsx

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2133,6 +2133,7 @@ class Grid extends PureComponent<GridProps, GridState> {
21332133
const { selectionRange, value, isQuickEdit } = editingCell;
21342134
const { column, row } = editingCell;
21352135
const {
2136+
scrollX,
21362137
gridX,
21372138
gridY,
21382139
allColumnXs,
@@ -2141,19 +2142,27 @@ class Grid extends PureComponent<GridProps, GridState> {
21412142
allRowHeights,
21422143
} = metrics;
21432144

2145+
const { activeCellSelectionBorderWidth } = this.getTheme();
2146+
21442147
const x = allColumnXs.get(column);
21452148
const y = allRowYs.get(row);
21462149
const w = allColumnWidths.get(column);
21472150
const h = allRowHeights.get(row);
21482151

2152+
// make sure cell doeesn't go off the left side of the grid
2153+
const leftBorderOffset =
2154+
gridX + (x ?? 0) <= 0 && scrollX <= 0
2155+
? activeCellSelectionBorderWidth
2156+
: 0;
2157+
21492158
// If the cell isn't visible, we still need to display an invisible cell for focus purposes
21502159
const wrapperStyle: CSSProperties =
21512160
x != null && y != null && w != null && h != null
21522161
? {
21532162
position: 'absolute',
2154-
left: gridX + x,
2163+
left: gridX + x + leftBorderOffset,
21552164
top: gridY + y,
2156-
width: w,
2165+
width: w - leftBorderOffset,
21572166
height: h,
21582167
}
21592168
: { opacity: 0 };

packages/grid/src/GridRenderer.ts

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,6 @@ export class GridRenderer {
3030
// Default radius in pixels for corners for some elements (like the active cell)
3131
static DEFAULT_EDGE_RADIUS = 2;
3232

33-
// Default width in pixels for the border of the active cell
34-
static ACTIVE_CELL_BORDER_WIDTH = 2;
35-
3633
protected textCellRenderer = new TextCellRenderer();
3734

3835
protected dataBarCellRenderer = new DataBarCellRenderer();
@@ -2151,11 +2148,18 @@ export class GridRenderer {
21512148
context: CanvasRenderingContext2D,
21522149
state: GridRenderState,
21532150
column: VisibleIndex,
2154-
row: VisibleIndex,
2155-
borderWidth = GridRenderer.ACTIVE_CELL_BORDER_WIDTH
2151+
row: VisibleIndex
21562152
): void {
21572153
const { metrics, theme } = state;
2158-
const { allColumnWidths, allColumnXs, allRowHeights, allRowYs } = metrics;
2154+
const {
2155+
scrollX,
2156+
scrollY,
2157+
allColumnWidths,
2158+
allColumnXs,
2159+
allRowHeights,
2160+
allRowYs,
2161+
} = metrics;
2162+
const { activeCellSelectionBorderWidth: borderWidth } = theme;
21592163
const cellX = getOrThrow(allColumnXs, column);
21602164
const cellY = getOrThrow(allRowYs, row);
21612165
const cellW = getOrThrow(allColumnWidths, column);
@@ -2168,13 +2172,13 @@ export class GridRenderer {
21682172
let h = cellH + borderWidth;
21692173

21702174
// Make sure the outline is interior on the edge
2171-
if (x <= 0) {
2172-
w += x - 1;
2173-
x = 1;
2175+
if (x <= 0 && scrollX <= 0) {
2176+
w -= borderWidth - x;
2177+
x = borderWidth * 0.5;
21742178
}
2175-
if (y <= 0) {
2176-
h += y - 1;
2177-
y = 1;
2179+
if (y <= 0 && scrollY <= 0) {
2180+
h -= borderWidth - y;
2181+
y = borderWidth * 0.5;
21782182
}
21792183

21802184
const { lineWidth } = context;

packages/grid/src/GridTheme.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ export type GridTheme = {
8484
scrollBarActiveSelectionTickColor: NullableGridColor;
8585

8686
// Look of the current selection
87+
activeCellSelectionBorderWidth: number;
8788
selectionColor: GridColor;
8889
selectionOutlineColor: GridColor;
8990
selectionOutlineCasingColor: GridColor;
@@ -187,6 +188,7 @@ const defaultTheme: GridTheme = Object.freeze({
187188
scrollBarCasingWidth: 1,
188189
scrollSnapToColumn: false,
189190
scrollSnapToRow: false,
191+
activeCellSelectionBorderWidth: 2,
190192
selectionColor: '#4286f433',
191193
selectionOutlineColor: '#4286f4',
192194
selectionOutlineCasingColor: '#222222',

packages/iris-grid/src/IrisGrid.scss

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,11 @@ $iris-grid-bar-max-height: 250px;
1414
$iris-grid-bar-max-width: $table-sidebar-max-width;
1515
$transition-iris-grid-bar-flash: 1s;
1616
$cell-box-shadow:
17-
0 0 0 2px var(--dh-color-accent),
17+
0 0 0 $active-cell-selection-border-width
18+
var(--dh-color-grid-selection-outline),
1819
0 0 0 5px accent-opacity(25);
1920
$cell-invalid-box-shadow:
20-
0 0 0 2px var(--dh-color-negative),
21+
0 0 0 $active-cell-selection-border-width var(--dh-color-negative),
2122
0 0 0 5px negative-opacity(25);
2223

2324
.iris-grid {
@@ -134,8 +135,8 @@ $cell-invalid-box-shadow:
134135
}
135136

136137
.grid-cell-input-field {
137-
color: $gray-200;
138-
background: $gray-800;
138+
color: var(--dh-color-input-fg);
139+
background: var(--dh-color-input-bg);
139140

140141
&:focus {
141142
box-shadow: $cell-box-shadow;

packages/iris-grid/src/IrisGridTheme.module.scss

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
$font-size: 12px;
55
$row-height: 19px;
66
$header-height: 30px;
7+
$active-cell-selection-border-width: 2px;
78

89
:export {
910
grid-bg: var(--dh-color-grid-bg);
@@ -29,6 +30,7 @@ $header-height: 30px;
2930
row-height: $row-height;
3031
row-background-colors: var(--dh-color-grid-row-0-bg)
3132
var(--dh-color-grid-row-1-bg);
33+
active-cell-selection-border-width: $active-cell-selection-border-width;
3234
selection-color: var(--dh-color-grid-selection);
3335
selection-outline-color: var(--dh-color-grid-selection-outline);
3436
selection-outline-casing-color: var(--dh-color-grid-selection-outline-casing);

packages/iris-grid/src/IrisGridTheme.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,9 @@ export function createDefaultIrisGridTheme(): IrisGridThemeType {
150150
reverseHeaderBarHeight: 4,
151151
filterBarHorizontalPadding: 4,
152152

153+
activeCellSelectionBorderWidth:
154+
parseInt(IrisGridTheme['active-cell-selection-border-width'], 10) || 2,
155+
153156
shadowAlpha: parseFloat(IrisGridTheme['row-shadow-alpha']) || 0.15,
154157

155158
// Amount of blur to apply to the bottom of the scrim while animating in

packages/iris-grid/src/__snapshots__/IrisGridTheme.test.ts.snap

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
exports[`createDefaultIrisGridTheme should derive the default Iris grid theme 1`] = `
44
{
5+
"activeCellSelectionBorderWidth": 2,
56
"allowColumnReorder": true,
67
"allowColumnResize": true,
78
"allowRowReorder": true,

0 commit comments

Comments
 (0)