Skip to content

feat(datatables): add tooltip support and custom button helper#111

Closed
sebastienheyd wants to merge 3 commits intomasterfrom
improve-button-tooltip
Closed

feat(datatables): add tooltip support and custom button helper#111
sebastienheyd wants to merge 3 commits intomasterfrom
improve-button-tooltip

Conversation

@sebastienheyd
Copy link
Owner

Summary

This PR improves upon #104 by adding tooltip support to DataTable buttons with several enhancements:

Features

  • ✅ Add tooltip functionality to datatable buttons with conditional rendering
  • ✅ Introduce custom() static helper method for simplified button creation
  • ✅ Smart parameter ordering: icon before tooltip for better ergonomics
  • ✅ Intelligent empty icon handling to prevent unnecessary HTML generation

Improvements over #104

  • Parameter order: icon comes before tooltip (more intuitive)
  • Conditional rendering: Tooltip only added when non-empty (no title="")
  • Smart icon handling: Empty icons don't generate HTML markup
  • PSR-12 compliance: Single blank line spacing
  • Test coverage: 8 comprehensive tests included

API Usage

// Method 1: Fluent API
Button::add('My button')
    ->route('users.show', $user->id)
    ->tooltip('View details')
    ->icon('eye')
    ->color('primary')
    ->make();

// Method 2: Custom helper (icon before tooltip)
Button::custom(
    'users.edit',           // route
    $user->id,              // args
    'pencil-alt',           // icon (3rd parameter)
    'Edit user profile',    // tooltip (4th parameter)
    'warning',              // color
    ['data-action' => 'edit'] // attributes
);

Test Results

All 228 tests pass with 735 assertions.

Closes #104

Daniel and others added 2 commits February 25, 2025 18:19
Add tooltip to button make method
- Reorder parameters: icon before tooltip for better ergonomics
- Add conditional tooltip rendering to avoid empty title attributes
- Implement smart icon handling to prevent empty HTML generation
- Fix PSR-12 spacing (single blank line)
- Add comprehensive test suite with 8 tests covering all features
@sebastienheyd
Copy link
Owner Author

Closing this PR in favor of a cleaner branch. Reopening as a new PR based directly on master without the original #104 commits.

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 6f06873eed

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

* @param array $attributes
* @return string
*/
public static function custom(string $route, array|string $args = [], string $icon = '', string $tooltip = '', string $color = 'default', array $attributes = []): string

Choose a reason for hiding this comment

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

P2 Badge Accept mixed route args in Button::custom

Button::custom() narrows $args to array|string, which breaks the model-object usage that existing helpers already support (for example Button::edit(..., $role) in the codebase). In PHP this can coerce an Eloquent model to a JSON string via __toString(), so route() receives the wrong parameter value and generates incorrect URLs; for non-stringable objects it will throw a TypeError. Matching the mixed behavior used by show/edit/delete avoids this regression.

Useful? React with 👍 / 👎.

@sebastienheyd sebastienheyd deleted the improve-button-tooltip branch February 14, 2026 09:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant