FIX: Dismiss new keyboard shortcut not working (PR #13430)

The dismiss new keyboard shortcut (x,r) has been broken since 7a79bd7da3e0a59454a3c03f3be31e457d0b9fcc. A fix was done and JS tests were added in 006d52f32b8d61449dcdd42fa09b06b1573091b0 and b01e4738abe206cd1d09db74acacc743c457c374 but the test was not quite correct and so the bottom dismiss new button was not clicked.

This also fixes an issue with our keyboard shortcut click handling. If multiple elements matched the selector they were all clicked. Now we just click the first match.


dismiss-posts was only mentioned here, nowhere else in our codebase. Legacy I guess?

The logic here doesn’t feel right to me, $sel = $(selector); should always return a list so I think we can just do $sel[0].click() no matter the length of the list.

Hmm the fact that this can fire twice if buttons are clicked in a quick succession feels like we’re missing a disable on the buttons after the first click.

It’s not the same button firing twice, it’s two separate buttons firing at the same time because both of their selectors are present :slight_smile: