Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions static/app/components/organizations/hybridFilter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,11 @@ export interface HybridFilterProps<Value extends SelectKey>
* Useful for things like enforcing a selection count limit.
*/
disableCommit?: boolean;
/**
* Additional staged changes from external state that should trigger
* the Apply/Cancel buttons.
*/
hasExternalChanges?: boolean;
/**
* Message to show in the menu footer
*/
Expand Down Expand Up @@ -96,6 +101,7 @@ export function HybridFilter<Value extends SelectKey>({
checkboxWrapper,
checkboxPosition,
disableCommit,
hasExternalChanges = false,
...selectProps
}: HybridFilterProps<Value>) {
/**
Expand All @@ -115,11 +121,13 @@ export function HybridFilter<Value extends SelectKey>({
}, [onStagedValueChange, stagedValue]);

/**
* Whether there are staged, uncommitted changes. Used to determine whether we should
* show the "Cancel"/"Apply" buttons.
* Whether there are staged, uncommitted changes, or external changes. Used to determine
* whether we should show the "Cancel"/"Apply" buttons.
*/
const hasStagedChanges =
stagedValue.length !== value.length || !stagedValue.every(val => value.includes(val));
stagedValue.length !== value.length ||
!stagedValue.every(val => value.includes(val)) ||
hasExternalChanges;

const commit = useCallback(
(val: Value[]) => {
Expand Down
Loading