Procházet zdrojové kódy

Fix error when opening a label menu in sidebar (#9377)

Since #9170, opening the menu of a label in the sidebar throws
`TypeError: Cannot set properties of null (setting 'href')`, as the
menu of labels has no website link. The rest of the click handler is
then skipped, so for instance the menu does not flip upwards when there
is no room below it.

Assisted-by: Claude <noreply@anthropic.com>
Nikolai Shcheglov před 1 dnem
rodič
revize
1f6d7853b3
1 změnil soubory, kde provedl 1 přidání a 1 odebrání
  1. 1 1
      p/scripts/main.js

+ 1 - 1
p/scripts/main.js

@@ -1186,7 +1186,7 @@ function init_column_categories() {
 					.innerHTML.replace(/------/g, id);
 					.innerHTML.replace(/------/g, id);
 				div.insertAdjacentHTML('beforeend', template);
 				div.insertAdjacentHTML('beforeend', template);
 				dropdownMenu = div.querySelector('.dropdown-menu');
 				dropdownMenu = div.querySelector('.dropdown-menu');
-				dropdownMenu.querySelector('li.website > a').href = feed_web;
+				dropdownMenu.querySelector('li.website > a')?.setAttribute('href', feed_web); // Labels have no website
 				dropdownMenu.style.opacity = '0%'; // Hide initially to prevent dropdown flashing
 				dropdownMenu.style.opacity = '0%'; // Hide initially to prevent dropdown flashing
 				if (feed_web == '') {
 				if (feed_web == '') {
 					const website = div.querySelector('.item.link.website');
 					const website = div.querySelector('.item.link.website');