DEV: Do not rerender widgets on mouseup/mousedown (#21300)
Ran into an issue with these hooks preventing click events on anchors from completing (because the triggered rerender cancels the click). See: https://github.com/discourse/discourse-header-search/pull/24 This change should have no effect on existing usage of these hooks. Current usage is limited to: - legacy navigation (should be a no-op) - reactions plugin (should be a no-op) - discourse-header-search (will fix the issue!)
This commit is contained in:
parent
b1da670898
commit
d697fd5766
|
@ -192,6 +192,7 @@ export const DefaultNotificationItem = createWidget(
|
|||
method: "PUT",
|
||||
data: { id: this.attrs.id },
|
||||
});
|
||||
this.scheduleRerender();
|
||||
}
|
||||
},
|
||||
}
|
||||
|
|
|
@ -263,13 +263,20 @@ WidgetClickHook.setupDocumentCallback = function () {
|
|||
});
|
||||
|
||||
$(document).on("mousedown.discourse-widget", (e) => {
|
||||
nodeCallback(e.target, MOUSE_DOWN_ATTRIBUTE_NAME, (w) => {
|
||||
w.mouseDown(e);
|
||||
});
|
||||
nodeCallback(
|
||||
e.target,
|
||||
MOUSE_DOWN_ATTRIBUTE_NAME,
|
||||
(w) => {
|
||||
w.mouseDown(e);
|
||||
},
|
||||
{ rerender: false }
|
||||
);
|
||||
});
|
||||
|
||||
$(document).on("mouseup.discourse-widget", (e) => {
|
||||
nodeCallback(e.target, MOUSE_UP_ATTRIBUTE_NAME, (w) => w.mouseUp(e));
|
||||
nodeCallback(e.target, MOUSE_UP_ATTRIBUTE_NAME, (w) => w.mouseUp(e), {
|
||||
rerender: false,
|
||||
});
|
||||
});
|
||||
|
||||
$(document).on("mousemove.discourse-widget", (e) => {
|
||||
|
|
|
@ -55,7 +55,11 @@ module(
|
|||
assert.ok(!exists("li.read"));
|
||||
|
||||
await triggerEvent("li", "mouseup", { button: 1, which: 2 });
|
||||
assert.strictEqual(count("li.read"), 1);
|
||||
assert.strictEqual(
|
||||
count("li.read"),
|
||||
1,
|
||||
"only one item is marked as read"
|
||||
);
|
||||
assert.strictEqual(requests, 1);
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue