Skip to content

Conversation

@rmartinoscar
Copy link
Member

@rmartinoscar rmartinoscar commented Oct 27, 2025

Closes #1441

@coderabbitai
Copy link

coderabbitai bot commented Oct 27, 2025

📝 Walkthrough

Walkthrough

Centralizes Filament/Livewire integrations in a new FilamentServiceProvider, removes individual native(false) calls from Select fields across the codebase, moves Filament render hooks and Livewire dehydrate logic out of AppServiceProvider, and adds avatar file handling and service provider registration.

Changes

Cohort / File(s) Summary
Select native(false) removals
app/Extensions/Features/Schemas/JavaVersionSchema.php, app/Filament/Admin/Pages/Settings.php, app/Filament/Admin/Resources/Eggs/Pages/CreateEgg.php, app/Filament/Admin/Resources/Eggs/Pages/EditEgg.php, app/Filament/Components/Forms/Fields/CopyFrom.php, app/Filament/Pages/Auth/EditProfile.php, app/Filament/Server/Resources/Files/Pages/ListFiles.php, app/Filament/Server/Resources/Schedules/ScheduleResource.php, app/Livewire/Installer/PanelInstaller.php
Removed explicit ->native(false) calls from Select field declarations, relying on default/global Select behavior instead.
Avatar FileUpload enhancements
app/Filament/Admin/Resources/Users/UserResource.php
Configured avatar FieldUpload with directory('avatars'), disk('public'), custom formatting to return user-specific avatar path, and deletion handling for uploaded files.
Filament service provider (new)
app/Providers/Filament/FilamentServiceProvider.php
New provider registering Filament color mappings, Blade render hooks (page start/footer/styles/scripts), Livewire dehydrate listener (alert banner dispatch), Field hintCopy macro, and global Select::configureUsing(...) disabling native selects.
AppServiceProvider cleanup
app/Providers/AppServiceProvider.php
Removed Filament/Livewire render hooks, color/view registrations, Livewire dehydrate handler, and Field macro registrations previously present in this provider.
Providers registration
bootstrap/providers.php
Added App\Providers\Filament\FilamentServiceProvider::class to the returned providers array (other panel providers retained/relisted).

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant Laravel as Laravel Boot
  participant Providers as Registered Providers
  participant FilamentProv as FilamentServiceProvider
  participant AppProv as AppServiceProvider
  participant Livewire as Livewire Runtime
  participant Forms as Filament Forms

  Note over Laravel,Providers: Application boot sequence
  Laravel->>Providers: instantiate & boot providers
  Providers->>FilamentProv: call boot()
  activate FilamentProv
  FilamentProv->>FilamentProv: register color mappings
  FilamentProv->>FilamentProv: register Blade render hooks (page start/footer/styles/scripts)
  FilamentProv->>Livewire: attach dehydrate listener (alertBanner dispatch)
  FilamentProv->>FilamentProv: Field::macro(hintCopy)
  FilamentProv->>FilamentProv: Select::configureUsing(native(false))
  deactivate FilamentProv

  Providers->>AppProv: call boot()
  activate AppProv
  AppProv->>AppProv: (no Filament/Livewire hooks present)
  deactivate AppProv

  Note over Forms,FilamentProv: Runtime form rendering
  Forms->>FilamentProv: resolve Select config
  FilamentProv-->>Forms: apply global Select config (non-native by default)
  Livewire->>Forms: dehydrate -> Livewire listener may dispatch alertBanner
Loading

Pre-merge checks

❌ Failed checks (2 warnings)
Check name Status Explanation Resolution
Out of Scope Changes Check ⚠️ Warning While most changes are directly related to fixing the dropdown rendering issue by globally disabling native Select rendering, the PR includes modifications to the avatar FileUpload field in UserResource.php that appear unrelated to issue #1441. These changes include setting directory to avatars, configuring the public disk, adding formatting logic for user-specific avatar paths, and implementing deletion handling. These FileUpload modifications are not mentioned in the linked issue and do not contribute to resolving the Firefox dropdown rendering problem. Consider removing the out-of-scope FileUpload modifications from UserResource.php and creating a separate PR for avatar field enhancements if they are necessary improvements. This will keep the current PR focused on solving the specific rendering issue described in #1441.
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Title Check ✅ Passed The title "Refactor: add FilamentServiceProvider & globally make Select native(false)" clearly and specifically describes the two main changes in the changeset: the creation of a new FilamentServiceProvider class and the global configuration to disable native Select rendering. The title is concise, avoids unnecessary noise, and accurately captures the primary objectives from a developer's perspective. It is directly related to the substantial refactoring work shown in the changes.
Linked Issues Check ✅ Passed The linked issue #1441 describes a Firefox dropdown rendering bug where selected options appear as white text on white background, making them unreadable in Startup settings. The PR implements a solution by globally configuring Select::configureUsing() in the new FilamentServiceProvider to set native(false) for all Select components. This forces Filament's custom rendering instead of native browser dropdowns, which directly addresses the rendering issue described in the issue. The subsequent removal of individual native(false) calls from multiple files is consistent with this global configuration approach.

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 03302eb and 00868b1.

📒 Files selected for processing (1)
  • bootstrap/providers.php (1 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
bootstrap/providers.php (1)
app/Providers/Filament/FilamentServiceProvider.php (1)
  • FilamentServiceProvider (20-82)
🔇 Additional comments (1)
bootstrap/providers.php (1)

12-15: LGTM! Registration addresses Firefox dropdown issue.

The addition of FilamentServiceProvider properly centralizes Filament configuration, including the global Select::configureUsing(fn (Select $select) => $select->native(false)) that fixes the Firefox white-on-white dropdown readability issue mentioned in the PR objectives. The alphabetical ordering of Filament providers (AdminPanel, AppPanel, Filament, ServerPanel) also addresses the concern raised in the past review comments.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
app/Extensions/Features/Schemas/JavaVersionSchema.php (1)

54-55: Options mapping likely reversed (bug).

mapWithKeys closure args are ($value, $key). Current fn ($key, $value) flips label/value, breaking default/notIn matching.

Apply one of these fixes:

-    ->options(fn () => collect($server->egg->docker_images)->mapWithKeys(fn ($key, $value) => [$key => $value]))
+    ->options(fn () => collect($server->egg->docker_images)->mapWithKeys(fn ($value, $key) => [$key => $value]))

Or simplify if already associative:

-    ->options(fn () => collect($server->egg->docker_images)->mapWithKeys(fn ($key, $value) => [$key => $value]))
+    ->options(fn () => $server->egg->docker_images)
🧹 Nitpick comments (3)
app/Filament/Admin/Resources/Users/UserResource.php (1)

254-276: Optional: align avatar upload constraints with EditProfile.

EditProfile restricts to PNG via acceptedFileTypes(['image/png']) and sets a deterministic filename; here it’s looser and visible only when a PNG already exists. If consistency is desired, mirror the restriction.

Example:

 FileUpload::make('avatar')
+    ->acceptedFileTypes(['image/png'])
     ->directory('avatars')
     ->disk('public')
app/Providers/Filament/FilamentServiceProvider.php (2)

38-40: Prefer component alias in Livewire render hook for compatibility.

@livewire(\FQCN::class) can be brittle across Livewire versions/parsers. Use the component alias/tag.

- fn () => Blade::render('@livewire(\App\Livewire\AlertBannerContainer::class)'),
+ fn () => Blade::render("@livewire('alert-banner-container')"),
+ // or: Blade::render('<livewire:alert-banner-container />')

57-71: Dehydrate listener is fine; small guard suggestion.

Dispatching for every component may be redundant. Optionally gate to root component to reduce event noise.

Example:

- on('dehydrate', function (Component $component) {
+ on('dehydrate', function (Component $component) {
+     if (method_exists($component, 'isRoot') && !$component->isRoot()) {
+         return;
+     }
      // existing checks...
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 3bcdeea and 03302eb.

📒 Files selected for processing (13)
  • app/Extensions/Features/Schemas/JavaVersionSchema.php (1 hunks)
  • app/Filament/Admin/Pages/Settings.php (0 hunks)
  • app/Filament/Admin/Resources/Eggs/Pages/CreateEgg.php (0 hunks)
  • app/Filament/Admin/Resources/Eggs/Pages/EditEgg.php (0 hunks)
  • app/Filament/Admin/Resources/Users/UserResource.php (2 hunks)
  • app/Filament/Components/Forms/Fields/CopyFrom.php (0 hunks)
  • app/Filament/Pages/Auth/EditProfile.php (2 hunks)
  • app/Filament/Server/Resources/Files/Pages/ListFiles.php (0 hunks)
  • app/Filament/Server/Resources/Schedules/ScheduleResource.php (1 hunks)
  • app/Livewire/Installer/PanelInstaller.php (0 hunks)
  • app/Providers/AppServiceProvider.php (0 hunks)
  • app/Providers/Filament/FilamentServiceProvider.php (1 hunks)
  • bootstrap/providers.php (1 hunks)
💤 Files with no reviewable changes (7)
  • app/Filament/Components/Forms/Fields/CopyFrom.php
  • app/Filament/Admin/Resources/Eggs/Pages/EditEgg.php
  • app/Filament/Admin/Pages/Settings.php
  • app/Livewire/Installer/PanelInstaller.php
  • app/Filament/Admin/Resources/Eggs/Pages/CreateEgg.php
  • app/Providers/AppServiceProvider.php
  • app/Filament/Server/Resources/Files/Pages/ListFiles.php
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2025-10-07T14:44:18.583Z
Learnt from: notAreYouScared
PR: pelican-dev/panel#1779
File: app/Filament/Admin/Resources/Users/Pages/EditUser.php:51-51
Timestamp: 2025-10-07T14:44:18.583Z
Learning: In the Pelican Panel codebase, when using Filament's FileUpload component for the avatar field in UserResource, the 'avatar' key is intentionally unset from the data array in EditUser::handleRecordUpdate before passing to UserUpdateService. This is by design because the avatar is not stored in the database directly—Filament's FileUpload component handles file storage, retrieval, and deletion through its own lifecycle hooks (formatStateUsing, deleteUploadedFileUsing, etc.) independently of the database update service.

Applied to files:

  • app/Filament/Admin/Resources/Users/UserResource.php
🧬 Code graph analysis (3)
bootstrap/providers.php (1)
app/Providers/Filament/FilamentServiceProvider.php (1)
  • FilamentServiceProvider (20-82)
app/Filament/Pages/Auth/EditProfile.php (1)
app/Services/Helpers/LanguageService.php (2)
  • LanguageService (8-30)
  • getAvailableLanguages (22-29)
app/Filament/Admin/Resources/Users/UserResource.php (1)
app/Services/Helpers/LanguageService.php (2)
  • LanguageService (8-30)
  • getAvailableLanguages (22-29)
🔇 Additional comments (7)
app/Extensions/Features/Schemas/JavaVersionSchema.php (1)

59-59: LGTM: relying on global Select native(false).

Keeping preload() here is good for large option sets. No further changes needed.

app/Filament/Pages/Auth/EditProfile.php (1)

135-135: LGTM: native(false) removal aligns with global config.

Selects remain searchable; behavior stays consistent via FilamentServiceProvider.

Also applies to: 146-146

app/Filament/Admin/Resources/Users/UserResource.php (1)

239-239: LGTM: Selects rely on global native(false).

No functional change; searchable and options logic preserved.

Also applies to: 254-254

app/Filament/Server/Resources/Schedules/ScheduleResource.php (1)

258-258: LGTM: consistent with global Select configuration.

selectablePlaceholder(false) remains; UX unchanged except for unified non‑native rendering.

bootstrap/providers.php (1)

8-8: No duplicate registrations found—placement is correct.

The verification confirms all Filament global configurations (color scheme, render hooks, macros, Select settings) are properly centralized in the single FilamentServiceProvider::boot() method with no redundant registrations elsewhere. Loading this provider early ensures hooks and macros initialize before panel providers depend on them.

app/Providers/Filament/FilamentServiceProvider.php (2)

78-78: Global Select native(false) set correctly — but manual verification needed on opt-in capability.

The search for native(true) overrides returned no matches. This may be expected if no fields currently require native behavior, or if the opt-in mechanism hasn't been exercised yet. Confirm that:

  • Fields can still opt-in via ->native(true) when needed (e.g., mobile, large lists)
  • The codebase is in the intended state post-deployment

48-55: Resolve — Vite hooks won’t double‑load app assets.

Search found only the @Vite calls for app.css/js in app/Providers/Filament/FilamentServiceProvider.php (the two render hooks) and a docs view (resources/views/docs/api-index.blade.php); Filament render hooks are additive — no other inclusions of resources/css/app.css or resources/js/app.js were found, so these hooks will not cause duplicate loads in panel layouts.

@rmartinoscar rmartinoscar requested a review from Boy132 October 29, 2025 00:18
@rmartinoscar rmartinoscar merged commit e6aa76e into main Oct 29, 2025
25 checks passed
@rmartinoscar rmartinoscar deleted the chore/filamentServiceProvider branch October 29, 2025 22:23
@github-actions github-actions bot locked and limited conversation to collaborators Oct 29, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Firefox: Dropdown menu white-on-white (unreadable)

3 participants