Skip to content

Commit

Permalink
DRY up conditionals
Browse files Browse the repository at this point in the history
  • Loading branch information
getdave authored and retrofox committed Oct 29, 2019
1 parent f7eea8b commit 8b0e864
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions packages/block-editor/src/components/url-input/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,9 @@ class URLInput extends Component {
static getDerivedStateFromProps( { value, disableSuggestions }, { showSuggestions, selectedSuggestion } ) {
let shouldShowSuggestions = showSuggestions;

if ( ! value || ! value.length ) {
const hasValue = value && value.length;

if ( ! hasValue ) {
shouldShowSuggestions = false;
}

Expand All @@ -247,7 +249,7 @@ class URLInput extends Component {
}

return {
selectedSuggestion: value && value.length ? selectedSuggestion : null,
selectedSuggestion: hasValue ? selectedSuggestion : null,
showSuggestions: shouldShowSuggestions,
};
}
Expand Down

0 comments on commit 8b0e864

Please sign in to comment.