Separate responsive controls from first column contents #5719
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 theclick
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.