Posting this here because this one is status-reviewed, hopefully it helps whoever handles the ticket.
It appears that in duplicate-targets-edited they've forgotten to provide a callback to asyncLoad
which would normally handle making the originals clickable:
This is the current code:
addButton.click(function (e) {
addButton.loadPopup({
url: '/questions/originals/' + questionId + '/find-originals-popup',
target: $('.container')
})
.done(function ($popup) {
StackExchange.vote_closingAndFlagging.close_initDuplicateSubPane();
$popup.asyncLoad();
There should be a callback to StackExchange.vote_closingAndFlagging.close_afterLoadListOriginals
which is not currently being done:
addButton.loadPopup({
url: '/questions/originals/' + questionId + '/find-originals-popup',
target: $('.container')
})
.done(function ($popup) {
StackExchange.vote_closingAndFlagging.close_initDuplicateSubPane();
$popup.asyncLoad({
callback: StackExchange.vote_closingAndFlagging.close_afterLoadListOriginals
});
It does work elsewhere because when navigating to the duplicate closure window from the standard close dialogue the callback is appropriately attached in full.en.js
paneToShow
.addClass('popup-active-pane')
.show()
.trigger('show')
.asyncLoad({
callback: closeAfterLoadListOriginals
});
In the meantime, here's a simple UserScript that fixes the problem by simply overwriting the duplicateTargetsEdited
with the fixed implementation:
// ==UserScript==
// @name Fix Edit Originals
// @version 0.0.1
//
// @match *://*.stackoverflow.com/questions/originals/*/edit
//
// @run-at document-start
//
// @grant none
//
// ==/UserScript==
/* globals StackExchange */
(function () {
'use strict';
const overWriteWithFix = () => {
Object.defineProperty(StackExchange, 'duplicateTargetsEdited', {
get() {
return function (questionId, questionUrl) {
var saveButton = $('.js-save-origs');
var addButton = $('.js-add-orig');
var list = $('.js-originals-list');
var countOriginals = function () {
return $('.js-originals-list .js-remove-orig').length;
};
var getOriginalIds = function () {
return list.find('.js-remove-orig').map(function (i, v) {
return $(v).data('id');
});
};
var updateButtons = function () {
var originalCount = countOriginals();
saveButton.enable(originalCount > 0 && originalCount <= 5);
addButton.enable(originalCount < 5);
};
addButton.click(function (e) {
addButton.loadPopup({
url: '/questions/originals/' + questionId + '/find-originals-popup',
target: $('.container')
})
.done(function ($popup) {
StackExchange.vote_closingAndFlagging.close_initDuplicateSubPane();
$popup.asyncLoad({
callback: StackExchange.vote_closingAndFlagging.close_afterLoadListOriginals
});
$('#add-original-form').submit(function (ev) {
ev.preventDefault();
var newOriginal = parseInt($('.js-original-question-id').val(), 10);
var existingOrigs = getOriginalIds();
for (var i = 0; i < existingOrigs.length; i++) {
if (existingOrigs[i] == newOriginal) {
$popup.find('.js-add-original').showErrorMessage(__tr(["The selected question is already listed!"], undefined, "en", []), {
relativeToBody: false,
position: {at: 'left center', my: 'right top'},
css: {'z-index': 10}
});
return;
}
}
$.get('/questions/originals/get-original-row/' + newOriginal, function (html) {
list.append(html);
})
.fail(function () {
setTimeout(function () {
addButton.showErrorMessage(__tr(["Error fetching question details. Please try again."], undefined, "en", []), {
relativeToBody: true,
position: {at: 'right center', my: 'left top'},
css: {'z-index': 10}
});
}, 0);
})
.always(function () {
StackExchange.helpers.closePopups();
updateButtons();
});
});
// the short story here is that initialization doesn't complete until the "show" event is triggered.
// but we can't trigger that NOW, because the popup isn't actually visible yet
// popup gets faded in after this callback returns...
// so, spin the event loop and listen for animation completed after it has had time to start.
// all this for the sake of re-using the duplicate dialog logic unchanged
setTimeout(function () {
$popup.promise().then(function () {
$popup.find(".close-as-duplicate-pane").trigger("show");
});
}, 0);
});
e.preventDefault();
});
list.on('click', '.js-remove-orig',
function (e) {
$(this).closest('.js-original-question').remove();
updateButtons();
e.preventDefault();
}
);
saveButton.click(function (e) {
var originals = getOriginalIds().toArray();
$.post('/questions/originals/' + questionId + '/save-originals', {
originalsIdsJson: JSON.stringify(originals),
fkey: StackExchange.options.user.fkey
}).done(
function () {
location.href = questionUrl;
}
).fail(
function (response) {
saveButton.showErrorMessage(response.responseJSON, {
relativeToBody: true,
position: {at: 'right center', my: 'left top', css: {'z-index': 10}}
});
}
);
e.preventDefault();
});
var $sortable = $('.js-originals-list.sortable');
StackExchange.loadJqueryUi().done(function () {
$sortable
.sortable({
axis: "y",
update: function () {
saveButton.enable();
}
});
});
}
}
});
}
if (window.StackExchange === undefined || Object.keys(window.StackExchange).length === 0) {
Object.defineProperty(window, 'StackExchange', {
configurable: true,
internalSE: undefined,
get() {
return this.internalSE;
},
set(newStackExchange) {
if (Object.keys(newStackExchange).length !== 0) {
delete window.StackExchange;
window.StackExchange = newStackExchange;
overWriteWithFix();
} else {
this.internalSE = newStackExchange;
}
}
});
} else {
overWriteWithFix();
}
}());