@izumisy-tailor/tailor-data-viewer 0.1.16 → 0.1.17

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
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@izumisy-tailor/tailor-data-viewer",
3
3
  "private": false,
4
- "version": "0.1.16",
4
+ "version": "0.1.17",
5
5
  "type": "module",
6
6
  "description": "Flexible data viewer component for Tailor Platform",
7
7
  "files": [
@@ -106,7 +106,7 @@ export function useTableData(
106
106
  hasNextPage: false,
107
107
  endCursor: null,
108
108
  });
109
- const [cursorHistory, setCursorHistory] = useState<string[]>([]);
109
+ const [cursorHistory, setCursorHistory] = useState<(string | null)[]>([]);
110
110
 
111
111
  const client = useMemo(() => createGraphQLClient(appUri), [appUri]);
112
112
 
@@ -286,10 +286,8 @@ export function useTableData(
286
286
 
287
287
  const nextPage = useCallback(() => {
288
288
  if (pagination.hasNextPage && pagination.endCursor) {
289
- // Store current cursor for back navigation
290
- if (pagination.after) {
291
- setCursorHistory((prev) => [...prev, pagination.after!]);
292
- }
289
+ // Store current cursor for back navigation (null for first page is valid)
290
+ setCursorHistory((prev) => [...prev, pagination.after]);
293
291
  // Use endCursor from pageInfo for pagination
294
292
  setPagination((prev) => ({
295
293
  ...prev,
@@ -301,11 +299,11 @@ export function useTableData(
301
299
  const previousPage = useCallback(() => {
302
300
  if (cursorHistory.length > 0) {
303
301
  const newHistory = [...cursorHistory];
304
- newHistory.pop();
302
+ const previousCursor = newHistory.pop();
305
303
  setCursorHistory(newHistory);
306
304
  setPagination((prev) => ({
307
305
  ...prev,
308
- after: newHistory.length > 0 ? newHistory[newHistory.length - 1] : null,
306
+ after: previousCursor ?? null,
309
307
  }));
310
308
  }
311
309
  }, [cursorHistory]);