-
Notifications
You must be signed in to change notification settings - Fork 4
Use specific rotation table selection state #435
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
776c6dd
Use separate rotation filter and selection state
BoraIneviNMI 2817551
Consider filters when building the rowSelection
BoraIneviNMI f53397b
Merge branch 'release/2026-01' into FDM314-rotation-selection
BoraIneviNMI bdf6512
Rename rotation selection state type
BoraIneviNMI 2a3e14d
Merge selection state with the previous
BoraIneviNMI 4d29eba
Merge branch 'release/2026-01' into FDM314-rotation-selection
SvenVw 99b2d9b
Fix unique ids
BoraIneviNMI File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| import { create } from "zustand" | ||
| import { createJSONStorage, persist } from "zustand/middleware" | ||
| import { ssrSafeSessionJSONStorage } from "./storage" | ||
|
|
||
| interface RotationSelectionState { | ||
| farmId: string | null | ||
| selection: Record<string, Record<string, boolean>> | ||
| updateSelection: ( | ||
| selection: Record<string, Record<string, boolean>>, | ||
| ) => void | ||
| syncFarm: (farmId: string) => void | ||
| } | ||
|
|
||
| export const useRotationSelectionStore = create<RotationSelectionState>()( | ||
| persist( | ||
| (set, get) => ({ | ||
| farmId: null, | ||
| selection: {}, | ||
| updateSelection( | ||
| selection: Record<string, Record<string, boolean>>, | ||
| ) { | ||
| const currentSelection = get().selection | ||
| const result: Record<string, Record<string, boolean>> = {} | ||
| for (const currentKey of Object.keys(currentSelection)) { | ||
| result[currentKey] = { ...currentSelection[currentKey] } | ||
| } | ||
| for (const key of Object.keys(selection)) { | ||
| result[key] = { ...(result[key] ?? {}), ...selection[key] } | ||
| } | ||
| set({ selection: result }) | ||
| }, | ||
| syncFarm(farmId: string) { | ||
| if (get().farmId !== farmId) { | ||
| set({ farmId, selection: {} }) | ||
| } | ||
| }, | ||
| }), | ||
| { | ||
| name: "rotation-selection-storage", // unique name | ||
| storage: createJSONStorage(() => ssrSafeSessionJSONStorage), // Use SSR-safe storage | ||
| }, | ||
| ), | ||
| ) |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🏁 Script executed:
cat -n fdm-app/app/components/blocks/rotation/table.tsx | head -150Repository: SvenVw/fdm
Length of output: 6107
🏁 Script executed:
sed -n '150,250p' fdm-app/app/components/blocks/rotation/table.tsxRepository: SvenVw/fdm
Length of output: 4004
🏁 Script executed:
sed -n '219,300p' fdm-app/app/components/blocks/rotation/table.tsxRepository: SvenVw/fdm
Length of output: 3400
🏁 Script executed:
rg -n "setSelection|selection\[" fdm-app/app/components/blocks/rotation/table.tsx -A 2 -B 2Repository: SvenVw/fdm
Length of output: 823
🏁 Script executed:
Repository: SvenVw/fdm
Length of output: 1111
Confirm: selection state of filtered-out rows is indeed lost.
The
handleSelectionfunction buildsnewSelectiononly fromtable.getFilteredRowModel().rows, then callssetSelection(newSelection), which completely replaces the stored selection. Any rows currently filtered out are excluded from this new selection object, causing their selection state to be discarded.To preserve selection for hidden rows, merge the new selection with the existing one instead of replacing it entirely:
🤖 Prompt for AI Agents