Skip to content

Commit

Permalink
Properly validate whether value exists
Browse files Browse the repository at this point in the history
  • Loading branch information
oandregal committed Nov 6, 2023
1 parent e41a1cc commit cd28877
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions packages/edit-site/src/components/dataviews/in-filter.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,15 @@ import {
const OPERATOR_IN = 'in';

export default ( { filter, view, onChangeView } ) => {
let activeValue = view.filters.find(
const valueFound = view.filters.find(
( f ) => f.field === filter.id && f.operator === OPERATOR_IN
)?.value;
);

const activeValue =
! valueFound || ! valueFound.hasOwnProperty( 'value' )
? ''
: valueFound.value;

if ( ! activeValue ) {
activeValue = '';
}
return (
<SelectControl
value={ activeValue }
Expand Down

0 comments on commit cd28877

Please sign in to comment.