Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Problem/Motivation
Currently, outside_in_contextual_links_view_alter() hardcodes a single contextual link as using offcanvas.
Any other links to be added will need the same logic.
Proposed resolution
Make it easier for contextual links to opt-in to being displayed in a dialog.
In #2784443: Move off-canvas functionality from Settings tray module into drupal.dialog.ajax library so that other modules can use it, make this available for all contextual links and all dialog/modal options.
Remaining tasks
User interface changes
API changes
Data model changes
Comment | File | Size | Author |
---|---|---|---|
#48 | 2820135-48.patch | 6.7 KB | tedbow |
#48 | interdiff-2820135-46-48.txt | 2.56 KB | tedbow |
#46 | allow_any_contextual-2820135-46.patch | 6.73 KB | yogeshmpawar |
#46 | interdiff-2820135-42-46.txt | 4.03 KB | yogeshmpawar |
#42 | allow_any_contextual-2820135-42.patch | 6.6 KB | yogeshmpawar |
Comments
Comment #2
tim.plunkettComment #3
tim.plunkettAlways write test coverage! Found a bug, it were overwriting existing class attributes.
Comment #4
tedbow@tim.plunkett thanks for this patch.
Looking at that patch I realized that outside.js is written so that any contextual link that used the offcanvas tray will always trigger edit mode. Long term we don't want this.
This patch separates this.
It also changes it so that a contextual link can designate it should trigger edit mode by
This will take care of other options. It is also possible to just specify that it should be a dialog.
If a link just needs to open in the offcanvas then:
Of course it could also specify 'modal' only.
I think in #2784443: Move off-canvas functionality from Settings tray module into drupal.dialog.ajax library so that other modules can use it
We should move the dialog-* options handling to contextual modal because it should be possible for contextual link to work with dialog system which they cannot now regardless anything in Setting Tray module.
Comment #6
tim.plunkettI think this is out of scope.
Considering that we're still keeping the code I proposed adding anyway, why not do this first as above, and make the
outside-in-edit
bit a new issue?Comment #7
tedbowI doing my interdiff against #3 because I got rid of most of my changes in #4.
RE: #6
I changed the title/scope of this issue back to "Allow any contextual link to opt-in to being displayed via offcanvas"
Without of the change to
blockConfigureSelector
it actually won't be possible to opt in to offcanvas without also triggering Settings Tray module Edit Mode.Since we are trying to keep OffCanvas dialog and the Settings Tray module separate we need this to keep in scope with what the issue is trying to do. It was never an issue or noticed before because only this modules links were using offcanvas.
Comment #8
tedbowBlocked by #2821709: Allow links to open content in Offcanvas tray without edit mode being enabled.
Comment #9
tedbowMarking as child of #2815831: Move Off-canvas related CSS from drupal.outside_in library to drupal.off_canvas
Comment #10
tedbowwrong parent
Comment #11
tedbowBlocker #2821709: Allow links to open content in Offcanvas tray without edit mode being enabled. fixed.
Will work on patch
Comment #12
tedbowOk here is patch.
Interdiff from #3.
Comment #13
tedbowComment #14
tim.plunkettI would move the @todo inline so that it is more clear which part is being removed.
Comment #15
tedbow@tim.plunkett moved comments.
Comment #16
webchickDiscussing this with the team, it seems like this is a nice-to-have and so far we haven't seen any actual use cases for it. Switching to feature request.
Comment #17
webchickOops. :) Actually, this is pretty important from the standpoint of standardizing on ways for modules (e.g. Field Layout) to interact with the Settings Tray, however, the existing dialog system has the same limitations, so it remains a normal task.
Comment #18
tim.plunkettI wrote the initial PoC and tests, but it's been @tedbow's work since then, so I feel comfortable marking this as RTBC.
Comment #19
Wim LeersNit: s/add/attach/
Comment #21
tedbowSetting back to RTBC because it was DrupalCI error
Comment #23
tedbow#22 was random test failure and now passing
Comment #25
tedbowRandom failure back to RTBC, rinse and repeat ;)
Comment #26
alexpottThis shouldn't do anything. Since this is a unit test. However as we're loading code - let's make this a kernel test and be done. Then we don't need to worry about including code and we don't need to worry about other tests and code inclusion issues.
This looks like we could use an @dataProvider here instead. Which would make adding future test cases simpler.
Comment #27
tim.plunkettIf we make it a kernel test, then we can't use @covers for a global function. It seems like the test cleans up after itself, and \Drupal\Tests\Listeners\DrupalStandardsListener::checkValidCoversForTest() runs late enough that function_exist() returns FALSE again.
So that's a toss-up.
But +1 to using @dataProvider
Comment #28
tedbowHere is patch that leaves it as a Unit test but uses a dataprovider
Comment #29
tim.plunkettPrefer using a keyed array for a dataProvider, makes it easier to debug (it puts the string into the output if it fails!).
Interdiff is against #15
Is the require_once that problematic for a unit test?
Comment #30
tedbowSetting back to RTBC. Thanks @alexpott's concerns have been addressed.
Comment #31
webchick#27 sounds reasonable to me, but kicking back to @alexpott to make sure he thinks so, too. :)
Reviewed the patch and nothing stuck out to me though.
Comment #32
alexpottThis affects the test environment of every single unit test - we shouldn't be adding includes in unit tests. The @covers reason definitely is not a good enough reason to break this. If anything it means we need to file a bug against the @covers standards checker (which to be honest I'm not a huge fan of).
Comment #33
alexpottComment #34
tedbowOk this changes it to a Kernel test to get of the "required_once"
Comment #36
tedbowComment #38
tedbowNeeds reroll because of #2862625: Rename offcanvas to two words in code and comments. and other recent commits
Comment #39
rajeevkAttaching patch for re-roll.
Resolved conflict in core/module/outside_in/outside_in.module found in rebasing 8.4.x on last passed version.
Comment #41
tedbowThink this will have to be "off_canvas" not "offcanvas"
Actually I think all the occurrences of "offcanvas" in the patch should be replaced with "off_canvas". They are deal with the renderer.
See #2862625: Rename offcanvas to two words in code and comments.
Comment #42
yogeshmpawarChanges made as per comment #41.
Comment #44
tedbow@Yogesh Pawar thanks for the patch.
there are a couple other occurrences of ''offcanvas''
Also couple other things I didn't catch before.
Should be off_canvas
Should be off_canvas
This logic cannot be removed. It causes a test failure.
See \Drupal\Tests\outside_in\FunctionalJavascript\OutsideInBlockFormTest::testBlocks
$this->assertEquals('Quick edit', $link->getText(), "'Quick edit' is the first contextual link for the block.");
This logic cannot be removed:
See \Drupal\Tests\outside_in\FunctionalJavascript\OutsideInBlockFormTest::testCustomBlockLinks
Comment #45
yogeshmpawarComment #46
yogeshmpawarThanks @tedbow, for the suggestions. Added updated patch with interdiff, hope so test will not fail this time.
Comment #48
tedbow@Yogesh Pawar hopefully this will fix it.
I just have to move the new code outside of the if statement it was within.
Comment #49
jian he CreditAttribution: jian he commentedSetting back to RTBC. I have write some contextual links to test the patch #48 manually, it works great.
Comment #50
yogeshmpawarany update on this issue ? it's it RTBC since last 2 weeks.
Comment #51
tedbowI don't think we will need special logic for this once #2892942: Contextual links support options but not use them to generate links is supported.
That issue was committed and then reverted because it is needs test. If you want this functionality then working on that issue will get it.
I briefly did #2893978: Use newly supported 'options' in contextual links in Settings Tray contextual links before the revert but this will show you how it works.
Comment #52
tedbowChanging to new settings_tray.module component. @drpal thanks for script help! :)