drupalContextualLinkAdded
$el => jQuery
$region => jQuery
model => StateModel
|
AuralView
KeyboardView
RegionView
VisualView
StateModel (Backbone model +):
title
regionIsHovered
hasFocus
isOpen
isLocked
toggleOpen()
close()
focus()
blur()
collection: Backbone collection of
models: array of StateModel
regionViews: array of RegionView
views: array of objects:
aural => AuralView
keyboard => KeyboardView
visual => VisualView
events bound on backbone models:
change (from the *Views models, triggers a renrender)
change:hasFocus (from the regionView model)
|
AuralView (not exposed)
VisualView (not exposed)
StateModel (Backbone model +):
isViewing
isVisible
contextualCount
tabbingContext
countContextualLinks()
lockNewContextualLinks()
updateVisibility()
model => StateModel
events bound on model:
change
change:contextualCount
change:isViewing
events bound on collection:
add
remove
reset
|
el
cid
$el
prototype:
$
bind
delegate
delegateEvents
initialize
listenTo
listenToOnce
off
on
once
preinitialize
remove
render
setElement
stopListening
tagName
trigger
unbind
undelegate
undelegateEvents
|
cid
attributes
changed
prototype:
bind
chain
changed
changedAttributes
cidPrefix
clear
clone
destroy
escape
fetch
get
has
hasChanged
idAttribute
initialize
invert
isEmpty
isNew
isValid
keys
listenTo
listenToOnce
matches
off
omit
on
once
pairs
parse
pick
preinitialize
previous
previousAttributes
save
set
stopListening
sync
toJSON
trigger
unbind
unset
url
validationError
values
|
length
models
prototype:
add
all
any
at
bind
chain
clone
collect
contains
countBy
create
detect
difference
drop
each
entries
every
fetch
filter
find
findIndex
findLastIndex
findWhere
first
foldl
foldr
forEach
get
groupBy
has
head
include
includes
indexBy
indexOf
initial
initialize
inject
invoke
isEmpty
keys
last
lastIndexOf
listenTo
listenToOnce
map
max
min
model
modelId
off
on
once
parse
partition
pluck
pop
preinitialize
push
reduce
reduceRight
reject
remove
reset
rest
sample
select
set
shift
shuffle
size
slice
some
sort
sortBy
stopListening
sync
tail
take
toArray
toJSON
trigger
unbind
unshift
values
where
without
|
Comments
Comment #2
claudiu.cristeaI wonder if we can’t replace it with pure CSS, see https://css-tricks.com/solved-with-css-dropdown-menus/
Comment #3
droplet commented#2,
the dropdown will or should be replaced with #1899236: Add new Splitbutton render element to eventually replace Dropbutton
I think we should do simple conversion first and tweaks later (easier review)
Comment #4
claudiu.cristea@droplet, it seems that splitbutton is still based on JS.
Comment #7
kim.pepperComment #8
jptarantoA CSS only solution wouldn't be accessible.
Comment #9
larowlanLooks like there's a merge request here for review
Comment #11
bnjmnmCould not find any contrib JS customization of contextual links
Summary of what Backbone is doing:
Comment #12
bnjmnmGitlab isnt letting me create 9.4 branches at the moment, so here's a 9.4 reroll as a patch.
Comment #14
nod_opened a new issue to not have to deal with missing branches and rebasing 500+ commits #3275400: Contextual backbone removal.
I'll probably post the patches here once it's good to go.
Comment #15
nod_updated IS with API changes
Comment #16
nod_Comment #17
nod_Code from #3275400: Contextual backbone removal that I'll close.
Comment #18
larowlanThis didn't apply anymore after, straight re-roll, reviewing the code locally
Comment #19
larowlanPart way done reviewing, will continue tomorrow
should we use Object.assign here while we're touching this file or would you prefer to leave that to one of the jquery eslint issues?
the comment on this method still refers to 'sets up model and views' so we should be able to reword that now
similarly here, its just a 'model view' now rather than two things
should we replace this with querySelector whilst we're here?
should we change the signature of initContextual now to not require a jQuery object as the argument?
there's going to be some BC breaks here we can't avoid already, so should we bundle that change in here too and give us a way to remove jQuery without a further break?
we can still init it as a jQuery object inside the function to avoid moving too much around in this issue
we fire this here and in initContextual, (which calls this), which seems wrong - should we only fire it once?
there's a lot of new jQuery here, should we be adding new jQuery code?
All of this can be done with vanilla js
Comment #21
larowlansecond half of review, onto manual testing now
We call this a lot, should we keep a hash of the properties that can change and only do the work if they've actually changed?
this is the same event body as on contextualmodelview, should we make it a static and use the same thing in both places?
event.keyCode is deprecated, so should we use event.code now or do we still care about IE11 (for now)
odd mix of vanilla and jquery here?
why was this changed needed?
Comment #22
larowlanManually tested as follows:
* Install umami
* Navigate to recipe
* Tab to edit button in toolbar
* Activate edit mode
* Confirm tabbing constrained to contextual links
* Confirm menu can be opened via keyboard
* Confirm links work via keyboard
* Confirm Esc key exits tabbing constraint
* Confirm works via mouse/hover
* Confirms menu can be opened and links can be clicked
Comment #24
longwaveNeeds a reroll - should this be targeted at 10.0.x now, given that we can't remove the deprecated code until then anyway?
Comment #25
longwaveComment #26
vsujeetkumar commentedRe-roll patch created for 9.5.x, Please have a look.
Comment #27
vsujeetkumar commentedComment #28
tvb commentedPatch from #26 could be applied.
Comment #30
smustgrave commentedThis issue is being reviewed by the kind folks in Slack, #need-reveiw-queue. We are working to keep the size of Needs Review queue [2700+ issues] to around 200, following Review a patch or merge require as a guide.
D10 version needed
At this time we would need a D10.1.x patch or MR for this issue.
Careful reroll
The patch can be tricky to reroll. When rerolling this issue please make sure all the parts of the patch are kept (new files, new tests, all the changes to the different parts of the file, changes to es6 files ported to .js files, etc.)
Comment #31
_utsavsharma commentedTried to re-roll for 10.1.x.
Created new files as well as deleted the ones which were deleted in #26.
Please review.
Comment #32
bnjmnm#31 is missing ModelView and ToolbarModelView. Try another reroll but have it come from an earlier patch (whatever patch you reroll from should be over 80kb)
Comment #33
sahil.goyal commentedAs per the comment #30 a reroll is required but in comment 31 can be seen that few files are missing as said in #32 so i updating the reroll patch and attaching the intra_diff file along with the patch, please review if needed something to modified please suggest and move back as needed.
Comment #34
sahil.goyal commentedComment #35
smustgrave commentedErrors in patch
Comment #36
karishmaamin commentedFixed some of indentation error. Keeping it Needs work to fix PHPStan error
Comment #37
nikhil_110 commentedRe-roll patch #36 and Try to fix Cs issue
Comment #38
nitin shrivastava commentedfix command failures #37
Comment #39
prem suthar commentedTry To Fix the #38 Patch.
Comment #41
vsujeetkumar commented@Prem Suthar, Interdiff is missing in #39, We should add that along with the patch. Its help to the reviewers to find the difference and what are the changes we have made from last patch. Also some Tests fails because some of the files are missing in the patch. Please compare with #26.
Re-roll patch needed for 11.x.
Comment #42
vsujeetkumar commentedRe-roll patch created for 11.x, We have added some missing JS files according to #26 and not include es6.js files with reference of this document. Keeps as is "Needs work" because we have some unaddressed comments above.
Comment #43
catch#3484850: [PP-1] [meta] Deprecate Toolbar module will be unblocked soon, which will leave this as the last remaining usage of backbone in Drupal core. It would be great to be able to remove the backbone library from Drupal 12. Bumping this to major. Looks like the next step here is converting the patch to an MR.
Comment #44
larowlanRebased the MR off 11.x
Comment #45
larowlanComment #46
smustgrave commentedFixed the pipeline so it would run but appears to have broken a few tests.
Comment #47
larowlanFixed the bad reroll which could have been me but also could have been a previous iteration.
Seems to be working locally in manual testing.
Comment #48
larowlanFailing tests look valid
Comment #49
larowlanThere were some underscore references left behind. Got rid of those because they're not needed in 2025 - we have native methods
Spot checked some tests locally and its looking good
Comment #50
nicxvan commentedThere is a functional JS failure that looks relevant, I can't rerun it since a core committer created the branch.
Comment #51
larowlanYep it's a real fail
Closing the contextual link list used to place focus on the trigger but that isn't happening now.
Tried a few things but they all end up in a loop
Will revisit this week
Comment #52
larowlanDug some more into the final fail
The issue is that when the dialog is opened from the contextual link that uses ajax and a dlalog, when jQueryUI attempts this code
we've already blurred the link and hence there's no focussed element to use as the opener, which means we can't return the focus.
Any ideas @bnjmnm?
Comment #53
larowlanRealized that the order events was being attached were different so re-ordered to ensure that ajax events are added first.
Also worked to reduce the amount of re-renders.
Then also tried using a targeted event (e.g. click.contextualLinks)
None of those helped
Comment #55
nod_Tried to go back a few commits and fixed a problem with hovering out of a region and contextual links not closing, not sure it's the same issue as #51 but it was broken before and now it's not. Can you let me know how to reproduce the failure with dialog?
opened a new MR to not erase the work in case it's a different bug.
Also all the comments have been removed, would be good to keep them around, they help with understanding what's going on
Comment #56
nod_could reproduce the problem with ajax using contextual_test module.
It seems it's the event delegation that used to be in backbone that was making things work. Somewhere it was switched to direct event binding and because there is so much re-rendering the event listeners were trashed and it caused issues apparently.
Comment #57
nod_Comment #58
nod_MR is green, need the comments added back for the various function we copy/pasted.
Comment #61
larowlanAdded the docs back
Comment #62
larowlanThis is green and should be pretty close, thanks @nod_ for the last fix
Comment #63
nicxvan commentedI can't content on the mr for some reason.
Some comments could still use cleanup:
Otherwise looks good, JS is not my forte though.
Comment #64
larowlanAddressed feedback, ready for review again
Comment #65
nicxvan commentedOk, I think this is ready.
I tested manually both in 11.x and this branch locally.
I tested block and view contextual links and tested with both mouse and keyboard. As far as I can tell both act exactly the same.
I searched for references to backbone, the only references remaining are for toolbar. There are no more references in contextual.
Javascript is not my forte as mentioned, but I am familiar with it, reviewing the code directly I see nothing that looks amiss.
As far as I can tell both larowlan and _nod have worked on this to a non trivial extent.
The only thing I didn't check that may be worth it is performance. I'm not super familiar with JS performance testing so I'll leave that up to a committer to determine if it's necessary.
_nod's comment in 56 make me think the change has been addressed as far as I can tell.
I added a CR too.
Comment #67
nod_Committed d381523 and pushed to 11.x. Thanks!