Просмотр исходного кода

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 1 день назад
Родитель
Сommit
1f6d7853b3
1 измененных файлов с 1 добавлено и 1 удалено
  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);
 				div.insertAdjacentHTML('beforeend', template);
 				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
 				if (feed_web == '') {
 					const website = div.querySelector('.item.link.website');