ui icon indicating copy to clipboard operation
ui copied to clipboard

Table->onRowClick() - Ignore click on checkboxes

Open acicovic opened this issue 5 years ago • 2 comments

Table->onRowClick() should not execute its action when a checkbox gets checked or unchecked.

acicovic avatar Feb 01 '21 13:02 acicovic

@acicovic please provide simple steps to replicate, if you know how to fix it, please submit a PR

mvorisek avatar Jul 27 '21 09:07 mvorisek

No time for this unfortunately. I will ping @ibelar, I think it would be simple for him to see if this issue is still a thing.

This is the function I had made up to get the correct selector. This mainly excluded the checkbox column and action menu.

    protected function generateRowClickSelector($class = 'handle-row-click')
    {
        $this->table->addClass("{$class} selectable");

        $excludeColumns = [];

        if (!empty($this->selection)) {
            $excludeColumns[] = ':first-child';
        }

        if (!empty($this->actionMenu)) {
            $excludeColumns[] = ':last-child';
        }

        $selector = "table.{$class} tr td";
        if (!empty($excludeColumns)) {
            $selector .= ":not('".implode(',', $excludeColumns)."')";
        }

        return $selector;
    }

And an example of how I used it:

    /**
     * Executes model User Action when row is clicked.
     */
    protected function executeUserActionOnRowClick(string $action): void
    {
        $selector = $this->generateRowClickSelector();

        $this->on('click', $selector, $this->model->getUserAction($action), [
            $this->table->jsRow()->data('id'),
        ]);
    }

This was done on a class overriding Grid.

Hope that helps.

acicovic avatar Aug 05 '21 19:08 acicovic

Fixed by #1655

mkrecek234 avatar Sep 05 '22 20:09 mkrecek234

@mkrecek234 when some PR fixes some issue, the issue is closed by that PR when merged, no need to close it before...

mvorisek avatar Sep 05 '22 20:09 mvorisek

This is a duplicate issue so no need to keep this topic open twice.

mkrecek234 avatar Sep 06 '22 02:09 mkrecek234

where is the 2nd one?

the PR says it fixes this one...

mvorisek avatar Sep 06 '22 03:09 mvorisek

You are right, I had erroneously memorised the PR discussion as an issue. Reopening until you contribute the test😉

mkrecek234 avatar Sep 06 '22 04:09 mkrecek234