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

Disable extra empty query in DefaultGlobalSearchProvider on page load/navigate for every resource that can be searched globally #14827

Open
wants to merge 1 commit into
base: 3.x
Choose a base branch
from

Conversation

Cybrarist
Copy link

@Cybrarist Cybrarist commented Nov 18, 2024

Description

when global search active for resources, an empty search query runs when the page loads, the following query is running for each resource available globally.

select * from 'models' where ('name' like '%%') limit 50

as it's not needed until the user searches.

Visual changes

Before :
Screenshot 2024-11-18 at 11 09 54 AM

After:
Screenshot 2024-11-18 at 11 10 32 AM

Functional changes

  • Code style has been fixed by running the composer cs command.
  • Changes have been tested to not break existing functionality.
  • Documentation is up-to-date.

if you don't want to use collection you can use an array instead

$resourceResults = ($query) ? $resource::getGlobalSearchResults($query) : [];

if ($resourceResults && ! $resourceResults->count()) {
    continue;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Todo
Development

Successfully merging this pull request may close these issues.

1 participant