Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

URLInput: keep the search results label in sync with the results list #45806

Merged
merged 9 commits into from
Nov 28, 2022
Prev Previous commit
Next Next commit
URLInput: put the current input value to state, in sync with search r…
…esults
  • Loading branch information
jsnajdr committed Nov 28, 2022
commit 3ff9d20160ee0579e3f22ce970a74c489ba17c97
11 changes: 6 additions & 5 deletions packages/block-editor/src/components/url-input/index.js
Original file line number Diff line number Diff line change
@@ -66,6 +66,7 @@ class URLInput extends Component {
suggestions: [],
showSuggestions: false,
isUpdatingSuggestions: false,
suggestionsValue: null,
selectedSuggestion: null,
suggestionsListboxId: '',
suggestionOptionIdPrefix: '',
@@ -172,6 +173,7 @@ class URLInput extends Component {
this.setState( {
suggestions: [],
showSuggestions: false,
suggestionsValue: value,
selectedSuggestion: null,
loading: false,
} );
@@ -201,6 +203,7 @@ class URLInput extends Component {
this.setState( {
suggestions,
isUpdatingSuggestions: false,
suggestionsValue: value,
loading: false,
showSuggestions: !! suggestions.length,
} );
@@ -486,13 +489,12 @@ class URLInput extends Component {
const {
className,
__experimentalRenderSuggestions: renderSuggestions,
value = '',
__experimentalShowInitialSuggestions = false,
} = this.props;

const {
showSuggestions,
suggestions,
suggestionsValue,
selectedSuggestion,
suggestionsListboxId,
suggestionOptionIdPrefix,
@@ -527,9 +529,8 @@ class URLInput extends Component {
buildSuggestionItemProps,
isLoading: loading,
handleSuggestionClick: this.handleOnClick,
isInitialSuggestions:
__experimentalShowInitialSuggestions &&
! ( value && value.length ),
isInitialSuggestions: ! suggestionsValue?.length,
currentInputValue: suggestionsValue,
} );
}