- How do I add a context menu to a Filament resource page?
- Use the `PageHasContextMenu` trait on your resource page class. Define actions via Filament’s `actions()` method, then register them with the context menu using `contextMenuActions()`. The package automatically integrates them into the right-click menu.
- Can I use this package with Filament v4 or v5?
- Yes, but you must install the correct version: `aymanalhattami/filament-context-menu:^3.0` for Filament v5, `^2.0` for v4, and `^1.0` for v3. Check the [README](https://github.com/aymanalhattami/filament-context-menu) for version-specific installation commands.
- How do I add a context menu to a specific table cell?
- Replace your existing column with `ContextMenuTextColumn` (or similar) and define `contextMenuActions()` in the column class. This scopes the menu to that cell only, using the same Filament Actions system.
- Are there built-in actions like 'Delete' or 'Export'?
- No, but you can reuse any Filament Action (e.g., `DeleteAction`, `ExportAction`) by registering them in `contextMenuActions()`. The package includes `RefreshAction`, `GoBackAction`, and `GoForwardAction` out of the box.
- Will this work with custom Filament pages (not resources)?
- Yes, the package supports custom pages. Apply the `PageHasContextMenu` trait to your page class and define actions in the `getContextMenuActions()` method, just like you would for a resource.
- Does the context menu support dark mode and RTL layouts?
- Absolutely. The package automatically inherits Filament’s dark/light mode and RTL/LTR direction settings, ensuring visual consistency without additional configuration.
- How do I add dividers between menu items?
- Use the `contextMenuDivider()` method in your actions array. For example: `contextMenuActions([...], contextMenuDivider(), [...])`. This works for both page-level and table-cell menus.
- Can I dynamically update the context menu based on user roles?
- Yes, but you’ll need to conditionally return actions in `getContextMenuActions()`. Use Filament’s built-in auth helpers (e.g., `auth()->user()->can()`) to filter actions server-side before rendering.
- Are there performance concerns for large tables (e.g., 10K+ rows)?
- The package renders menus on-demand (right-click), so performance impact is minimal. For very large datasets, consider lazy-loading actions or using Filament’s built-in pagination to reduce row count.
- What if I need a custom action not covered by Filament’s Actions?
- Extend Filament’s `Action` class and register it via `contextMenuActions()`. For complex logic (e.g., API calls), use Filament’s `UrlAction` or `ModalAction` as a base, then override the `handle()` method.