CharrafiMed / global-search-modal

Enhances filamentphp's global search by transforming it into a modal for a better user experience
https://filamentphp.com/plugins/charrafimed-global-search-modal
69 stars 15 forks source link

Global Search Result Details Formatting #39

Closed NathanLochala closed 1 month ago

NathanLochala commented 1 month ago

When adding the function getGlobalSearchResultDetails(Model $record) to a resource, the resulting formatting when searching fails to justify to the left. Meaning, the text seems to have spaces add or is indented. It isn't fully justified to the left and inline with the title. There doesn't seem to be a pattern. I have a model that includes two Detail lines.

See below: Forgive the blurring, but the important part is seeing that each result returned isn't fully justified to the left. On the last search entry, the email isn't fully justified to the left, but the job title is. For the other results, the email is justified to the left, but the job title seems to have a random number of spaces added to the front of it. image

Here is another sanitized view. As you see, it doesn't seem to be padded with spaces or anything, however, clearly it is not justified to the left like I would expect the details (email and job title) to be: image

Here is my resource global search results methods:

class EmployeeResource extends Resource
{
    protected static ?string $model = Employee::class;
    protected static ?string $navigationGroup = 'Personnel';
    protected static ?string $navigationIcon = 'heroicon-c-user-group';

    /*###############################################################
    # GLOBAL SEARCH SETTINGS
    ###############################################################*/
    public static function getGloballySearchableAttributes(): array
    {
        return ['full_legal_name', 'email'];
    }

    public static function getGlobalSearchResultTitle(Model $record): string|Htmlable
    {
        return $record->full_name;
    }

    public static function getGlobalSearchResultDetails(Model $record): array
    {
        return [
            $record->email,
            optional($record->location)->name.' - '.$record->job_title,
        ];
    }

    public static function getGlobalSearchResultUrl(Model $record): string
    {
        return EmployeeResource::getUrl('view', ['record' => $record]);
    }
CharrafiMed commented 1 month ago

Thanks for bringing this up! I understand your concern. In my plugin, I initially copied the search details directly from Filament's implementation to maintain consistency with their design. Here's the snippet I based it on: image That being said, I agree that this could be improved for a better UI experience. I’ll work on updating the interface to make it more polished and user-friendly.

Before I get started, could you share how you'd like it to look? I'd to consider your preferences.

NathanLochala commented 1 month ago

I would like to see the $title and the $value to lineup on the left. For example, this is how it currently is: image

This is how I would like it to look: Xnip2024-09-16_12-56-45

If you look at the email address. In the first picture, the email address seems to have several spaces added to the front. In the second picture, the email address and the title are directly inline with each other. That is how I would expect it to work.