docs(changeset): Possible selection fixes

This commit is contained in:
Hein 2025-12-01 11:42:26 +02:00
parent b514c906c8
commit 7c1d47819a
4 changed files with 24 additions and 15 deletions

View File

@ -0,0 +1,5 @@
---
'@warkypublic/oranguru': patch
---
Possible selection fixes

View File

@ -238,9 +238,9 @@ export const GridlerDataGrid = () => {
JSON.stringify(currentSelection?.current) !== JSON.stringify(selection.current)
) {
setState('_gridSelection', { ...selection, rows });
if (JSON.stringify(currentSelection?.rows) !== JSON.stringify(rows)) {
setState('_gridSelectionRows', rows);
}
//if (JSON.stringify(currentSelection?.rows) !== JSON.stringify(rows)) {
setState('_gridSelectionRows', rows);
//}
}
//console.log('Selection', selection);

View File

@ -282,7 +282,12 @@ export const Computer = React.memo(() => {
const firstRow = firstBuffer?.[keyField];
const currentValues = getState('values') ?? [];
if (firstRow && firstRow > 0 && (currentValues.length ?? 0) === 0) {
if (
!(values && values.length > 0) &&
firstRow &&
firstRow > 0 &&
(currentValues.length ?? 0) === 0
) {
const values = [firstBuffer, ...(currentValues as Array<Record<string, unknown>>)];
const onChange = getState('onChange');
@ -340,10 +345,12 @@ export const Computer = React.memo(() => {
if (selectedRowKey) {
const onChange = getState('onChange');
const selected = [{ [getState('keyField') ?? 'id']: selectedRowKey }];
if (onChange) {
onChange(selected);
} else {
setState('values', selected);
if (JSON.stringify(getState('values')) !== JSON.stringify(selected)) {
if (onChange) {
onChange(selected);
} else {
setState('values', selected);
}
}
}

View File

@ -463,13 +463,10 @@ const { Provider, useStore: useGridlerStore } = createSyncStore<GridlerStoreStat
const [col, row] = cell;
if (state.glideProps?.onCellClicked) {
state.glideProps?.onCellClicked?.(cell, event);
} else {
if (state.values?.length) {
if (state.onChange) {
state.onChange(state.values);
} else {
state.setState('values', state.values);
}
}
if (state.values?.length) {
if (state.onChange) {
state.onChange(state.values);
}
}