Power-Components / livewire-powergrid

⚡ PowerGrid generates modern, powerful and easy-to-customize data tables using Laravel Livewire.
https://livewire-powergrid.com
MIT License
1.47k stars 215 forks source link

Button Redirect Route Opens a new window. #335

Closed oliveiraped closed 2 years ago

oliveiraped commented 2 years ago

First of all, did you see if your problem has happened to other people before?

Did you read the documentation ?

Is there an error in the console?

Describe the bug

Button redirect route will always open a new tab/window, instead of staying in the same browser.

To Reproduce

How its possible to disable this action, and stay on the same window

Laravel version (exactly)

"laravel/framework": "^9.2",

Livewire version (exactly)

"livewire/livewire": "^2.10", "power-components/livewire-powergrid": "^2.3"

AlpineJS:

*

Theme:

Screenshots (This helps to understand better)

Do you have any idea how we can fix it?

Put part of your code, an html screenshot of the problem element:

public function actions(): array { return [ Button::add('Items') ->caption(__('Items')) ->class('d-grid gap-2 col-6 mx-auto btn btn-info btn-sm') ->method('get') ->route('platforms.items', ['id' => 'id']),

dansysanalyst commented 2 years ago

Hi @oliveiraped,

Thank you for submitting an issue.

You can specify the target:

Button::add('Items')
  ->caption(__('Items'))
  ->class('d-grid gap-2 col-6 mx-auto btn btn-info btn-sm')
  ->method('get')
  ->route('platforms.items', ['id' => 'id'])
  ->target('_self'),

I will revise the doc now.

Hope you are enjoying the package!


⭐ Enjoying PowerGrid? Please consider Starring the repository! 📢 Share PowerGrid with your dev-community, friends and colleagues: Tweet, write a blog, record review video. 👥 PowerGrid is open-source, entirely developed and maintained by the author and the contributors.

oliveiraped commented 2 years ago

Hi Dan,

Thank you very much.

It worked.

Best Regards

Pedro

hansajith1998 commented 3 months ago
public function actions(User $row): array
    {
        return [
            Button::add('edit')
                ->slot("<i data-tw-merge data-lucide='pencil' class='stroke-[2] w-3.5 h-3.5 mx-auto block text-white'></i>")
                ->id('edit')
                ->class('transition duration-200 border shadow-sm inline-flex items-center justify-center rounded-md font-medium cursor-pointer focus:ring-none focus-visible:outline-none [&:hover:not(:disabled)]:bg-opacity-90 [&:hover:not(:disabled)]:border-opacity-90 [&:not(button)]:text-center disabled:opacity-70 disabled:cursor-not-allowed bg-[#ffc107] border-opacity-5 border-[#ffca2c] text-slate-900 dark:border-warning w-8 h-[1.63rem]')
                ->method('get')
                ->route('super_admin.users.edit', ['user' => $row->id])
                ->can(allowed: auth()->user()->can('users.update'))
                ->target('_self')
                ->tooltip('Edit user')
//                ->dispatch('edit', ['rowId' => $row->id])
        ];
    }

image

I have a button like this, rendering the HTML as a button (like the screenshot). The problem is it will not redirect to the edit page.. I haven't found any solution in the documentation