Skip to content

Commit 08db452

Browse files
authored
[WC-3311] [DropdownFilter] Fix for stale captions (#2117)
2 parents 5c91fe5 + b9888c4 commit 08db452

12 files changed

Lines changed: 37 additions & 30 deletions

File tree

packages/pluggableWidgets/datagrid-dropdown-filter-web/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66

77
## [Unreleased]
88

9+
### Fixed
10+
11+
- We fixed an issue with Dropdown filter captions not updating properly when their template parameters change.
12+
913
## [3.8.1] - 2026-02-19
1014

1115
### Changed

packages/shared/widget-plugin-dropdown-filter/src/controllers/BaseController.ts

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,16 @@ export interface BaseControllerProps<S extends FilterStore> {
2020
multiselect: boolean;
2121
onChange?: ActionValue;
2222
valueAttribute?: EditableValue<string>;
23-
emptyCaption?: string;
23+
emptySelectionCaption: string;
24+
emptyOptionCaption: string;
25+
ariaLabel: string;
26+
placeholder: string;
2427
}
2528

2629
type Gate<S extends FilterStore> = DerivedPropsGate<BaseControllerProps<S>>;
2730

2831
export class BaseController<S extends FilterStore> implements IJSActionsControlled {
32+
protected readonly gate: Gate<S>;
2933
protected actionHelper: JSActionsHelper;
3034
protected changeHelper: ValueChangeHelper;
3135
protected defaultValue?: Iterable<string>;
@@ -35,6 +39,7 @@ export class BaseController<S extends FilterStore> implements IJSActionsControll
3539

3640
constructor({ gate, multiselect }: { gate: Gate<S>; multiselect: boolean }) {
3741
const props = gate.props;
42+
this.gate = gate;
3843
this.filterStore = props.filterStore;
3944
this.multiselect = multiselect;
4045
this.serializer = new OptionsSerializer({ store: this.filterStore });
@@ -47,6 +52,22 @@ export class BaseController<S extends FilterStore> implements IJSActionsControll
4752
this.changeHelper = new ValueChangeHelper(gate, () => this.serializer.value);
4853
}
4954

55+
get emptyCaption(): string {
56+
return this.gate.props.emptySelectionCaption;
57+
}
58+
59+
get ariaLabel(): string {
60+
return this.gate.props.ariaLabel;
61+
}
62+
63+
get emptyOptionCaption(): string {
64+
return this.gate.props.emptyOptionCaption;
65+
}
66+
67+
get inputPlaceholder(): string {
68+
return this.gate.props.placeholder;
69+
}
70+
5071
parseDefaultValue = (value: string | undefined): Iterable<string> | undefined => {
5172
const defaultValue = this.serializer.fromStorableValue(value);
5273
if (!defaultValue) {

packages/shared/widget-plugin-dropdown-filter/src/controllers/EnumBaseController.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { EnumFilterStore } from "../stores/EnumFilterStore";
66
import { BaseController } from "./BaseController";
77

88
export class EnumBaseController extends BaseController<EnumFilterStore> {
9-
private readonly gate: DerivedPropsGate<EnumBaseControllerProps>;
9+
protected readonly gate: DerivedPropsGate<EnumBaseControllerProps>;
1010

1111
constructor({ gate, multiselect }: { gate: DerivedPropsGate<EnumBaseControllerProps>; multiselect: boolean }) {
1212
super({ gate, multiselect });

packages/shared/widget-plugin-dropdown-filter/src/controllers/EnumComboboxController.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,5 @@ import { ComboboxControllerMixin } from "./mixins/ComboboxControllerMixin";
55
export class EnumComboboxController extends ComboboxControllerMixin(EnumBaseController) {
66
constructor({ gate }: { gate: DerivedPropsGate<EnumBaseControllerProps> }) {
77
super({ gate, multiselect: false });
8-
this.inputPlaceholder = gate.props.placeholder;
9-
this.emptyCaption = gate.props.emptySelectionCaption;
10-
this.ariaLabel = gate.props.ariaLabel;
118
}
129
}

packages/shared/widget-plugin-dropdown-filter/src/controllers/EnumSelectController.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,5 @@ import { SelectControllerMixin } from "./mixins/SelectControllerMixin";
55
export class EnumSelectController extends SelectControllerMixin(EnumBaseController) {
66
constructor({ gate }: { gate: DerivedPropsGate<EnumBaseControllerProps> }) {
77
super({ gate, multiselect: gate.props.multiselect });
8-
this.emptyOption.caption = gate.props.emptyOptionCaption;
9-
this.emptyCaption = gate.props.emptySelectionCaption;
10-
this.ariaLabel = gate.props.ariaLabel;
118
}
129
}

packages/shared/widget-plugin-dropdown-filter/src/controllers/EnumTagPickerController.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,6 @@ export class EnumTagPickerController extends TagPickerControllerMixin(EnumBaseCo
1616

1717
constructor({ gate }: { gate: DerivedPropsGate<Props> }) {
1818
super({ gate, multiselect: gate.props.multiselect });
19-
this.inputPlaceholder = gate.props.placeholder;
20-
this.emptyCaption = gate.props.emptySelectionCaption;
21-
this.ariaLabel = gate.props.ariaLabel;
2219
this.filterSelectedOptions = gate.props.selectionMethod === "rowClick";
2320
this.selectedStyle = gate.props.selectedItemsStyle;
2421
this.selectionMethod = this.selectedStyle === "boxes" ? gate.props.selectionMethod : "checkbox";

packages/shared/widget-plugin-dropdown-filter/src/controllers/RefComboboxController.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,6 @@ import { RefBaseController, RefBaseControllerProps } from "./RefBaseController";
66
export class RefComboboxController extends ComboboxControllerMixin(RefBaseController) {
77
constructor({ gate }: { gate: DerivedPropsGate<RefBaseControllerProps> }) {
88
super({ gate, multiselect: false });
9-
this.inputPlaceholder = gate.props.placeholder;
10-
this.emptyCaption = gate.props.emptySelectionCaption;
11-
this.ariaLabel = gate.props.ariaLabel;
129
}
1310

1411
handleFocus = (event: FocusEvent<HTMLInputElement>): void => {

packages/shared/widget-plugin-dropdown-filter/src/controllers/RefSelectController.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,6 @@ import { SelectControllerMixin } from "./mixins/SelectControllerMixin";
55
export class RefSelectController extends SelectControllerMixin(RefBaseController) {
66
constructor({ gate }: { gate: DerivedPropsGate<RefBaseControllerProps> }) {
77
super({ gate, multiselect: gate.props.multiselect });
8-
this.emptyOption.caption = gate.props.emptyOptionCaption;
9-
this.emptyCaption = gate.props.emptySelectionCaption;
10-
this.ariaLabel = gate.props.ariaLabel;
118
}
129

1310
handleFocus = (): void => {

packages/shared/widget-plugin-dropdown-filter/src/controllers/RefTagPickerController.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,6 @@ export class RefTagPickerController extends TagPickerControllerMixin(RefBaseCont
1616

1717
constructor({ gate }: { gate: DerivedPropsGate<Props> }) {
1818
super({ gate, multiselect: gate.props.multiselect });
19-
this.inputPlaceholder = gate.props.placeholder;
20-
this.emptyCaption = gate.props.emptySelectionCaption;
21-
this.ariaLabel = gate.props.ariaLabel;
2219
this.filterSelectedOptions = gate.props.selectionMethod === "rowClick";
2320
this.selectedStyle = gate.props.selectedItemsStyle;
2421
this.selectionMethod = this.selectedStyle === "boxes" ? gate.props.selectionMethod : "checkbox";

packages/shared/widget-plugin-dropdown-filter/src/controllers/mixins/ComboboxControllerMixin.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,16 @@ type BaseController = GConstructor<{
1919
filterStore: FilterStore;
2020
multiselect: boolean;
2121
setup(): () => void;
22+
inputPlaceholder: string;
23+
emptyCaption: string;
24+
ariaLabel: string;
2225
}>;
2326

2427
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
2528
export function ComboboxControllerMixin<TBase extends BaseController>(Base: TBase) {
2629
return class ComboboxControllerMixin extends Base {
2730
touched = false;
2831
inputValue = "";
29-
inputPlaceholder = "";
30-
emptyCaption = "";
31-
ariaLabel = "";
3232

3333
constructor(...args: any[]) {
3434
super(...args);

0 commit comments

Comments
 (0)