Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Separate responsive controls from first column contents #5719

Merged
merged 9 commits into from
Nov 20, 2024

Conversation

pxpm
Copy link
Contributor

@pxpm pxpm commented Nov 19, 2024

WHY

BEFORE - What was wrong? What was happening before this PR?

It was not possible to have a link (<a href="...">) on the first column while having responsive table enabled.

I was always bugged by that, but didn't find the "motivation" to work on a solution for it.

Today while working on https://github.com/Laravel-Backpack/editable-columns/pull/79 I found out that editable columns had an "hacky" solution to address the before mentioned problem with responsive tables, introduced here: https://github.com/Laravel-Backpack/editable-columns/pull/14

This hacky solution had undesired side effects, like while trying to set the input to type=date for example, it wouldn't trigger the default input calendar for date selection as the click handler was hijacked.

Upon further investigation to datatables api I found out that it's possible to make the column "trigger the responsive modal" without displaying the "three dots" by using type: none in responsive table details configuration.

Also found that's possible for responsive table to configure the target that triggers the responsive functionality.

Connecting all the dots I came up with this solution, that only triggers the responsive modal when clicking in the target (three dots), and leaves the rest of the column free to have other behaviors, such an anchor 👍

AFTER - What is happening after this PR?

We can now have other triggers (clicks etc) in the first column content without interference from datatables responsive plugin.

It will allow me to remove the click hijack in the editable columns.

HOW

How did you achieve that, in technical terms?

Configured datatables to don't display the "controls" (three dots) for the responsive functionality.
Configured datatables to seek for a dtr-control class in the row to trigger the responsive functionality.
Manually added the "controls" similar to how we add the details row/bulk actions.

Is it a breaking change?

I don't think so.

How can we test the before & after?

Add a link in the first column and enable details row.

@pxpm
Copy link
Contributor Author

pxpm commented Nov 20, 2024

I've tested this on all themes, we are golden 👍

@pxpm pxpm merged commit 13f6fc4 into main Nov 20, 2024
8 checks passed
@pxpm pxpm deleted the separate-responsive-controls-from-first-column branch November 20, 2024 14:40
@falterkofler
Copy link

I'm not sure but I think this caused the 3 dots in the first column to disappear in all my list views on mobile, even if the first column is no custom column at all.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

4 participants