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.
Some more fix to the js, It should be changed to use backbone but while that gets done, the js needs to be fixed so that people don't copy some of the stuff that's in the JS.
Drupal.theme should not return jquery object. Quickedit doesn't need to, this doesn't either. Event binding is not something to have in a theme function.
fix jsdoc so that meaningful doc can be generated.
Other js fixes here.
Comment | File | Size | Author |
---|---|---|---|
#60 | interdiff-2785589-57-60.txt | 650 bytes | tedbow |
#60 | 2785589-60.patch | 15.93 KB | tedbow |
#57 | 2785589-57.patch | 15.93 KB | tedbow |
#54 | use-pressButton.patch | 15.93 KB | droplet |
#46 | interdiff-2785589-43-45.txt | 876 bytes | tedbow |
Comments
Comment #2
nod_Comment #3
tedbowBackbone part is duplicate of #2784935: Use Backbone for client-side state management
This issue was marked as outside_in.module component because it is new. I updated it
Comment #4
nod_Simplified the code. The ajax command was lacking, it's only a fancy insert command in the end. We could likely repurpose dialogs to implement this, anyway. Things are better now.
Fixed some initialization code.
Removed all ids and almost all classes from the JS, we should only select elements based on data attributes, that's what happens now.
Comment #6
nod_Oh right, depends on #2764931: Contextual links don't work with 'use-ajax' links.
Comment #7
nod_now depends on #2786459: "Offcanvas" tray should be using the existing dialog system too.
Comment #8
nod_Reroll.
Comment #9
nod_Reroll.
Comment #10
nod_Make use of data attributes instead of classes, put code that should be in a behavior in a behavior, fix missing library depenency.
Comment #12
tedbowThis is trying to close the offcanvas try on edit mode exit right? We are settings the data-drupal-canvas=close attribute anywhere. I couldn't see how could do this on the php side.
Only where I saw do it would be
in offcanvas.js
But even with that the namespaced event doesn't trigger anything
Comment #13
tedbowTalk with @nod_ about #12 and he said that was left over code.
Fixing though I don't see a way to use an attribute there.
Comment #14
riddhi.addweb CreditAttribution: riddhi.addweb commentedComment #15
nod_thanks for the reroll.
This is already the core queue, no need for a tag.
Comment #16
tedbowThis patches adds to \Drupal\Tests\outside_in\FunctionalJavascript\OutsideInBlockFormTest a check to make sure that when you exit edit mode the tray is closed also.
Comment #17
GrandmaGlassesRopeManMaybe move this selector string with the rest of them.
Maybe something like
setEditModeState
.Comment #18
tedbow@drpal good points fixed both those.
Yes I changed this and other references from "Active" to "EditMode"
I also update OutsideInBlockFormTest to check that you can click the "Drupal" link in the "Powered By Drupal" block and it will open the block form and not leave the page.
Comment #19
GrandmaGlassesRopeMan@tedbow
This patch has just a minor formatting issue at the bottom, could you reroll? Thanks.Sorry, error on my end. I haven't had coffee.Comment #20
GrandmaGlassesRopeMan@tedbow
Alright, this looks good. After applying this patch I didn't notice any regressions.
Comment #22
tedbow@droplet in #2782915-26: Standardize the behavior of links when Outside In editing mode is enabled suggested this change
Seems like a good idea to me but my only concern is that is search /core/misc and /core/modules I only find addEventListener once but see ".on(" tons. So it seems like the event bubbling is what is done more in core. Then again we are doing something different then most use cases, trying to suppress clicks for most elements.
I am new to JS in Drupal core so I am trying to go by what the current practice is. Maybe that is not a good idea or our use is very different(which it might be).
Comment #23
droplet CreditAttribution: droplet commentedDon't worry about it. It's a historic problem only.
the `domready` function in drupal.js based on addEventListener and it's used in Drupal widely. (and jQuery 2.x also)
Event Delegation (e.g. jQuery.on) still has its advantages but it's okay switch over to addEventListener if it's provided better workaround for particular cases :)
you may interesting in this post also, @see:
https://signalvnoise.com/posts/3137-using-event-capturing-to-improve-bas...
Comment #24
nod_yup, better solution. Instead of keeping the event listeners around and having a condition inside I just add and remove the events handlers when necessary. It's closer to what we're used to do everywhere else with attachBehaviors/detachBehaviors.
Comment #25
tedbowOk setting to RTBC since @nod_ and @droplet the 2 core JS maintainers seem to be ok with current patch.
Comment #26
webchickA core committer is unlikely to find anything here that those two can't, so committed and pushed to 8.2.x and 8.3.x. :) Thanks!
Comment #27
webchickComment #29
webchickHm, sorry, I lied. Committed and pushed to 8.3.x, but would not cherry-pick cleanly to 8.2.x for some reason. Probably needs a small re-roll.
Comment #31
xjmNot sure why @webchick's cherry-pick did not work but I was able to cherry-pick it and pushed that to 8.2.x.
Comment #32
alexpottI'm pretty sure that this needs reverting. When using outside_in the save button in the sidebar no longer works for me. Using git bisect I've narrowed it to this commit. I've tested on the latest versions of firefox, chrome and safari.
Steps to reproduce:
Comment #33
alexpott@catch has confirmed that he experiences that same problem and doing
git revert -n fdc09d3
fixes it. Going to revert this for now.Comment #34
alexpottReverted the commit on 8.3.x - committed d32af63 and pushed to 8.3.x.
Reverted the commit on 8.2.x - committed 6201818 and pushed to 8.2.x.
Comment #37
alexpottAnother thing this broke was "configure block" taking the user to the full configuration page.
Comment #38
tedbow@alexpott sorry for not catching this. Right now we don't have a JS test for submitting the form because of #2789381: Submitting an ajax dialog form in Javascript test throws a GastonJS error.
The problem was
document.addEventListener('click', preventClick, true);
This was preventing clicks on the whole document which obviously includes the offcanvas tray.
I have changed this to:
document.querySelector('#main-canvas').addEventListener('click', preventClick, true);
I have updated the preventClick to check first if the target is a contextual link so they will continue to work as normal.
One thing I have discovered in #2764931: Contextual links don't work with 'use-ajax' links is that we don't have JS tests for contextual links which makes it hard to test them here. For that issue I tried to write tests but kept running into #2773791: Clicking elements with children in Javascript tests throws a GastonJS exception or other GastonJS problems.
In #2782915: Standardize the behavior of links when Outside In editing mode is enabled I have added a bunch for JS Test coverage though I am not able to test form submitting or contextual links because of the aforementioned GastonJS bugs. But it does add JS coverage for about 6 other behaviors.
In that issue I did do a bit of a hacky work around to get around #2773791: Clicking elements with children in Javascript tests throws a GastonJS exception. We will see what others think of it. But it might allow testing of contextual links.
Comment #39
tedbowOk I update the JS test to address a couple of the issue covered in patch.
I was able to find a temporary workaround #2789381: Submitting an ajax dialog form in Javascript test throws a GastonJS error.
In the test I am using JS in test to click the submit button. This not ideal but I think better than no coverage. I have a @todo to remove this when GastonJS issue is solved.
I also added testing that the default action of links and form elements in the editables is suppressed during edit mode.
Comment #40
GrandmaGlassesRopeManWhile I'm in favor of using vanilla JS where possible, seems odd to start using it here to bind the click event handler.Looks like you already had this discussion previously.Add docs here to explain what's happening.
Comment #41
tedbow@drpal thanks for review!
I added a doc to that function and another 1 that was missing.
Comment #42
Wim Leers#38:
Yep. Contextual Links long predate JS testing (which we've had for about 6 months now): Almost 7 years ago, they were moved into a separate module, at #626286: Make contextual links a module. Kudos for working on JS tests for them! It will indeed be very very valuable to have test coverage for them.
Hm… now this issue is introducing a work-around, even though that's exactly what #2773791: Clicking elements with children in Javascript tests throws a GastonJS exception is doing. Speaking of which, it looks like #2789381: Submitting an ajax dialog form in Javascript test throws a GastonJS error is simply a duplicate of #2773791: Clicking elements with children in Javascript tests throws a GastonJS exception.
So, sadly… I think this is effectively blocked on #2773791: Clicking elements with children in Javascript tests throws a GastonJS exception. Since this is just a normal issue, I don't think it makes sense to rush this in; we should instead fix it properly in #2773791: Clicking elements with children in Javascript tests throws a GastonJS exception.
Comment #43
droplet CreditAttribution: droplet commentedUnlocked.
(I didn't review the patch anyway)
Comment #45
droplet CreditAttribution: droplet commentedSomething wrong, it passed in my local env (Phantomjs 2.1.1) .
#43 fixed one error anyway.
Trying to reduce the testing and see what happening.
Comment #46
tedbow@droplet thanks for patch.
I see that the only problem was dialog is not rendering the button slightly differently so the css selector for targeting the button needs to be updated.
This more boringly named patch does that.
EDIT: @droplet I didn't see your comment in #45 but I think my patch will fix the error in your patch in #43
Comment #47
droplet CreditAttribution: droplet commentedAhh. It looks like I'm running on an old code base. I just `git reset --hard && git pull` and see the errors.
Comment #51
droplet CreditAttribution: droplet commentedGreat! It's GREEN!!
Comment #52
tedbowOk so this no longer postponed so changed the title.
I think this is ready for RTBC.
@Wim Leers' review in #42 was all about the testing. There is still a @todo about switching to pressButton() but click() is working for now without #2773791: Clicking elements with children in Javascript tests throws a GastonJS exception. That is still important but doesn't block this issue.
@drpal's review in #40 I addressed in #41.
Comment #53
droplet CreditAttribution: droplet commentedBy the way:
Clicking actions catching the edge cases. But we need not test the Save action 3 times if that's time-consuming for testbots.
Comment #54
droplet CreditAttribution: droplet commentedWe can do it. Passing dynamic text into it. @todo is wrong notes I think.
I preferred click with selectors.
`pressButton()` is also calling `click()` in background but `pressButton()` helping you to locate the BUTTON from page without selectors.
Comment #55
tedbowOk switching to RTBC. @droplet's patch in #54 removed last @todo regarding GastonJS bug.
Comment #57
tedbowThis is only a reroll of #54 now that #2782803: Rename Outside-in module to "Settings Tray" in the UI and in comments was committed.
Also forgot to address this:
The save action actually only gets called 2 times in search_form_block doesn't need to test saving the form. It is just used to test opening the block form by clicking a form element in the block. This shows that clicking on form element don't trigger the regular form action.
Each of other blocks tests something different when saving
Comment #58
tedbowBumping this to major because it a major rewrite of the Javascript.
Comment #59
GrandmaGlassesRopeMan@tedbow
This looks good. Just one minor nit about jsodoc types.
This should be
boolean
.Comment #60
tedbow@drpal ok great. fixed the jsdoc.
Comment #61
webchickLooks like the tests asked for by @alexpott were accounted for in #39.
I'll confess I have no idea what 90% of this is. ;) But it's largely by our JS maintainers, and it's against an experimental module, soooo...
Committed and pushed to 8.2.x and 8.3.x! (Take two.) Thanks!
Comment #64
alexpottComment #66
tedbowChanging to new settings_tray.module component. @drpal thanks for script help! :)