fix: row selection with incorrect values

This commit is contained in:
Hein
2026-02-11 11:09:35 +02:00
parent 95e2973d44
commit afb7a3346f
2 changed files with 8 additions and 3 deletions

View File

@@ -71,7 +71,7 @@ export const Computer = React.memo(() => {
//When values change, update selection
useEffect(() => {
const searchSelection = async () => {
const searchSelection = async (values: Array<Record<string, unknown>>) => {
const page_data = getState('_page_data');
const pageSize = getState('pageSize');
const keyField = getState('keyField') ?? 'id';
@@ -85,6 +85,9 @@ export const Computer = React.memo(() => {
? values?.[vi]
: undefined
);
if (!key) {
continue;
}
for (const p in page_data) {
for (const r in page_data[p]) {
const idx = Number(p) * pageSize + Number(r);
@@ -115,7 +118,7 @@ export const Computer = React.memo(() => {
};
if (values) {
searchSelection().then((rowIndexes) => {
searchSelection(values).then((rowIndexes) => {
let rows = CompactSelection.empty();
rowIndexes.forEach((r) => {
if (r !== undefined) {

View File

@@ -336,7 +336,9 @@ const { Provider, useStore: useGridlerStore } = createSyncStore<GridlerStoreStat
},
getRowIndexByKey: async (key: number | string) => {
const state = get();
if (key === undefined || key === null) {
return undefined;
}
let rowIndex = -1;
if (state.ready) {
const page_data = state._page_data;