block editor – Gutenberg LinkControl suggestionsQuery not working


I have a link control like so:

import { __ } from "wordpress user/i18n";
import {
  __experimentalLinkControl as LinkControl,
} from "wordpress user/block-editor";
import "./editor.scss";

export default function ({ attributes, setAttributes }) {

  return (
              type: "post",
              subtype: "page",

However, typing into the search input shows all post types (I want it to just show pages). The documentation says to use it as so:


Type: Object
Required: No
Controls the query
parameters used to search for suggestions. For example, to limit a
query to just Page types use:

    suggestionQuery={ {
        type: 'post',
        subtype: 'page',
    } }

I think I’ve followed that pretty nicely.

The only question in my mind is, the docs also state:

Data sources

By default LinkControl utilizes the __experimentalFetchLinkSuggestions API from core/block-editor in order to retrieve search suggestions for matching post-type entities.

By default this provides no functionality and so you must implement and provide this in your own Editor instance (example).

The example:

I cannot wrap my head around. It also may not be why my code isn’t working. Would anyone be able to show how I can make this work?

Djave 2 years 2021-12-09T10:59:06-05:00 0 Answers 0 views 0

Leave an answer