issue editing page, quirk removing artefacts
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Mahara |
New
|
Undecided
|
Unassigned |
Bug Description
Mahara 15.10.0, Php 5.6.12, Postgres 9.3.5
Problem removing artefact DOM element(s) when editing page (after page has been displayed)
reproducible on Mac OS X 10.9.5
Chrome 46.0.2490.86 (64bit)
Safari 9.0.1 99637.86.2.7.2)
Firefox 42.0
To reproduce
Create a portfolio page
add a journal artefact to the page (or any other artefact)
add another artefact (doesn't matter what kind)
Display page (this is crucial, everything works as expected in edit mode)
Go back and edit the page
delete one of your artefacts and it gets removed from the DOM as expected
try to delete another artefact and it will appear to work but DOM will NOT be updated unless you reload page
problem found in
js/views.js
lines 538 button.on('click' ....)
the variable blockinstanceID is a global so far is the onclick function is concerned so the first time through the routine it is undefined, then on lines 546 - 548 it is set properly to the data-id attribute of the artefact you are trying to delete
When you try to delete another artefact from the page blockinstanceId retains the value from the previous call and is NOT set to the current artefacts data-id. (i.e. assignment on line 547 is skipped)
a potential fix (though I don't particularly like it)
after line 559 where the DOM element is removed add
blockinstanceId= undefined;
The only place where rewriteDeleteButton is called and blockinstanceId is 'defined' is on line 1099 setting up for the removecancel button on click function. Another fix might be to have that routine call it's own rewriteDeleteButton (maybe refactor rewriteDeleteButton ) and have onClick use it's own local blockinstanceId which is always assumed to be null.
Hi Gary,
Thanks for the bug report!
I think this is the same bug as Bug 1511536, which we actually just released a fix for in Mahara 15.10.1.
Cheers,
Aaron