I am working with a customer who is looking to dynamically add filters on the initialUIState and onStateChange. The onStateChange function is being called and when applying the uiState with the new filters, it is ignored if the "configure" widget is present with "filters" or "optionalFilters". Is this by design or a defect on the InstantSearch.js library? here is the code sample which currently has a static value for the filters to test this working first before add the dynamic filter retrieval.
initialUiState: {
"dev_docs_global_en-id-20251205205710890": {
configure: {
filters: "docRegion:us",
},
},
},
onStateChange: function ({ uiState, setUiState }) {
const stateReplica = uiState;
Object.entries(stateReplica).forEach(([key, value]) => {
console.log(`Key: ${key}, Value: ${value}`);
if (key.includes("_docs_")) {
console.log("Change");
stateReplica[key] = {
...value,
configure: {
...value.configure,
filters: `docRegion:us`,
},
};
}
});
setUiState(stateReplica);
},