Skip to content

Commit 9470c89

Browse files
fix (TOBACCO-1585): clear default filters when changing select type. Fix encode URI for data-categories
1 parent df16ef5 commit 9470c89

2 files changed

Lines changed: 6 additions & 4 deletions

File tree

plugins/wp-react-blocks-plugin/blocks/posts-filter/BlockEdit.jsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ class BlockEdit extends BlockEditWithFilters {
8484
label={__('Filter Type')}
8585
value={filterType}
8686
onChange={(filterType) => {
87-
setAttributes({ filterType: filterType });
87+
setAttributes({ filterType: filterType, defaultValues: [] });
8888
}}
8989
options={[
9090
{ label: "Single select", value: "single-select" },
@@ -99,7 +99,8 @@ class BlockEdit extends BlockEditWithFilters {
9999
onChange={() => setAttributes({
100100
isCountryFilter: !isCountryFilter,
101101
isYearFilter: false,
102-
selectedYear: null
102+
selectedYear: null,
103+
defaultValues: []
103104
})} />
104105

105106
<ToggleControl
@@ -109,7 +110,8 @@ class BlockEdit extends BlockEditWithFilters {
109110
onChange={() => setAttributes({
110111
isYearFilter: !isYearFilter,
111112
isCountryFilter: false,
112-
selectedYear: null
113+
selectedYear: null,
114+
defaultValues: []
113115
})} />
114116

115117
</PanelBody>

plugins/wp-react-blocks-plugin/blocks/posts-filter/BlockSave.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ const SaveComponent = (props) => {
4949
data-all-none-same-behaviour={allNoneSameBehaviour}
5050
data-auto-apply={autoApply}
5151
data-taxonomy={taxonomy}
52-
data-categories={categories.toString()}
52+
data-categories={encodeURIComponent(JSON.stringify(categories))}
5353
data-is-country-filter={isCountryFilter}
5454
data-is-year-filter={isYearFilter}
5555
data-selected-year={selectedYear}

0 commit comments

Comments
 (0)