mirror of
https://github.com/rr-/szurubooru.git
synced 2025-07-17 08:26:24 +00:00
client/general: add empty href for link buttons
Ine464e69
I removed href='#' but I noticed that it broke some things. Readding href serves two purposes: - it makes links reachable with Tab key - it makes links clickable with Enter key The alternative to this approach was to introduce [tabindex] and [role] attributes. But not only using tabindex=0 with <a/> is questionable, it'd require adding a keyboard handler that'd intercept space and return key presses and simulated link clicks. Since it's best to leave this kind of thing to the native UI, I went with readding hrefs instead. I believe that hash hrefs, even though being a common practice, are silly, so I decided to settle down with empty hrefs. As a bonus, I added a snippet that prevents middle mouse clicks from opening such links/buttons in new tabs, which was the motivation fore464e69
.
This commit is contained in:
@ -476,6 +476,14 @@ document.addEventListener('input', e => {
|
||||
}
|
||||
});
|
||||
|
||||
// prevent opening buttons in new tabs
|
||||
document.addEventListener('click', e => {
|
||||
if (e.target.getAttribute('href') === '' && e.which === 2) {
|
||||
console.log('prevented');
|
||||
e.preventDefault();
|
||||
}
|
||||
});
|
||||
|
||||
module.exports = misc.arrayToObject([
|
||||
htmlToDom,
|
||||
getTemplate,
|
||||
|
Reference in New Issue
Block a user