Page field search bar doesn't use search plugin

I have written a custom search plugin and it works like a charm in the panel search bar, however I can’t figure out how to get the search bar in the page field popup to use my plugin.

I see that the popup does a request to /related but I can’t figure out what “area” I have to use to get my custom search results in there.

the url that the related page search goes to is this:

/api/pages/{{id}}/fields/blocks/fieldsets/pages/fields/related?page=0&search={{query}}

I have made some progress:

if I use this:


'components' => [
    'search' => function (Kirby $kirby, Collection $collection, string $query = null, $params = []) {
      // only replace the search component for Pages collections
      if (is_a($collection, 'Kirby\Cms\Pages') === true) {
        return tick_search_pages($query);
      }

      // use the native component for other searches (users, files...)
      return $kirby->nativeComponent('search')($kirby, $collection, $query, $params);
    }
  ]

I apparently am on the right track because I can generate an error.
the error is this:

Argument 2 passed to Kirby\Filesystem\F::{closure}() must be an instance of Collection, instance of Kirby\Cms\Pages given, called in /kirby/kirby-3.6/src/Cms/Search.php on line 40