@linzjs/step-ag-grid 29.1.6 → 29.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
package/src/components/Grid.tsx
CHANGED
|
@@ -238,11 +238,29 @@ export const Grid = <TData extends GridBaseRow = GridBaseRow>({
|
|
|
238
238
|
}, [autoSizeColumns, gridRenderState, params, rowData, sizeColumns, sizeColumnsToFit]);
|
|
239
239
|
|
|
240
240
|
const lastOwnerDocumentRef = useRef<Document>();
|
|
241
|
+
const wasVisibleRef = useRef(false);
|
|
241
242
|
|
|
242
243
|
/**
|
|
243
244
|
* Auto-size windows that had deferred auto-size
|
|
245
|
+
* Reset focus if panel went from invisible to visible.
|
|
244
246
|
*/
|
|
245
247
|
useInterval(() => {
|
|
248
|
+
// If grid has become visible after previously being hidden, then refocus the last focused cell.
|
|
249
|
+
const visible = !!gridDivRef.current?.checkVisibility();
|
|
250
|
+
if (visible && !wasVisibleRef.current) {
|
|
251
|
+
wasVisibleRef.current = true;
|
|
252
|
+
const el = (window as any).__stepaggrid_lastfocuseventtarget;
|
|
253
|
+
if (el) {
|
|
254
|
+
// Setting this to null will cause a new refocus event
|
|
255
|
+
(window as any).__stepaggrid_lastfocuseventtarget = null;
|
|
256
|
+
// Check element is still part of document
|
|
257
|
+
if (el.checkVisibility()) {
|
|
258
|
+
el.focus();
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
wasVisibleRef.current = visible;
|
|
263
|
+
|
|
246
264
|
// Check if window has been popped out and needs resize
|
|
247
265
|
const currentDocument = gridDivRef.current?.ownerDocument;
|
|
248
266
|
if (currentDocument !== lastOwnerDocumentRef.current) {
|
|
@@ -625,7 +643,7 @@ export const Grid = <TData extends GridBaseRow = GridBaseRow>({
|
|
|
625
643
|
|
|
626
644
|
const onCellFocused = useCallback(
|
|
627
645
|
(event: CellFocusedEvent<TData>) => {
|
|
628
|
-
if (
|
|
646
|
+
if (event.rowIndex == null) {
|
|
629
647
|
return;
|
|
630
648
|
}
|
|
631
649
|
const api = event.api;
|
|
@@ -639,15 +657,17 @@ export const Grid = <TData extends GridBaseRow = GridBaseRow>({
|
|
|
639
657
|
if (!colDef || typeof colDef === 'string') {
|
|
640
658
|
return;
|
|
641
659
|
}
|
|
642
|
-
// Prevent repeated callbacks to cell focus when
|
|
660
|
+
// Prevent repeated callbacks to cell focus when focus didn't change
|
|
643
661
|
const { sourceEvent } = event;
|
|
644
662
|
if (sourceEvent) {
|
|
645
|
-
|
|
663
|
+
const cell = (sourceEvent.target as unknown as Element).closest('.ag-cell');
|
|
664
|
+
if ((window as any).__stepaggrid_lastfocuseventtarget === cell) {
|
|
646
665
|
return;
|
|
647
666
|
}
|
|
648
|
-
(window as any).__stepaggrid_lastfocuseventtarget =
|
|
667
|
+
(window as any).__stepaggrid_lastfocuseventtarget = cell;
|
|
649
668
|
}
|
|
650
|
-
|
|
669
|
+
|
|
670
|
+
paramsOnCellFocused?.({ colDef, data });
|
|
651
671
|
},
|
|
652
672
|
[paramsOnCellFocused],
|
|
653
673
|
);
|