document.addEventListener(“DOMContentLoaded”, function () { const mainHeaderMenu = document.querySelector(“.main-header-menu”); if (!mainHeaderMenu) return; const mainMenuItemsWithChildren = mainHeaderMenu.querySelectorAll(“.wp-block-navigation-item.has-child”); const customContainer = document.querySelector(“.custom-submenu-container”); if (!customContainer) return; // Create overlay const overlay = document.createElement(“div”); overlay.classList.add(“custom-overlay”); document.body.appendChild(overlay); let isMenuOpen = false; let currentSubmenu = null; let eventListeners = new Map(); // Store event listeners for clean removal let hoverTimeout = null; function isDesktopView() { return window.innerWidth >= 768; } function openDesktopMenu(menuItem) { const submenu = menuItem.querySelector(“.wp-block-navigation__submenu-container”); if (!submenu) return; const submenuClone = submenu.cloneNode(true); customContainer.innerHTML = “”; customContainer.appendChild(submenuClone); customContainer.style.display = “flex”; overlay.style.display = “block”; isMenuOpen = true; currentSubmenu = menuItem; } function closeDesktopMenu() { customContainer.style.display = “none”; overlay.style.display = “none”; isMenuOpen = false; currentSubmenu = null; } // Function to add desktop-specific event handlers function setupDesktopBehavior() { if (!isDesktopView()) return; // First, remove any previously set listeners to avoid duplicates removeAllEventListeners(); mainMenuItemsWithChildren.forEach(menuItem => { // Hover handlers with better event handling const mouseEnterHandler = function (e) { // Clear any pending close timeout if (hoverTimeout) { clearTimeout(hoverTimeout); hoverTimeout = null; } // Only open if not already showing this menu if (currentSubmenu !== menuItem) { openDesktopMenu(menuItem); } }; const mouseLeaveHandler = function (e) { // Check if we’re actually leaving the menu item area const relatedTarget = e.relatedTarget; // Don’t close if moving to the custom container or staying within menu item if (relatedTarget && ( customContainer.contains(relatedTarget) || menuItem.contains(relatedTarget) )) { return; } // Delay closing to allow moving to submenu hoverTimeout = setTimeout(() => { closeDesktopMenu(); }, 200); }; eventListeners.set(menuItem, { mouseEnterHandler, mouseLeaveHandler }); menuItem.addEventListener(“mouseenter”, mouseEnterHandler); menuItem.addEventListener(“mouseleave”, mouseLeaveHandler); // Click handlers (for toggle behavior) const clickHandler = function (e) { e.preventDefault(); e.stopPropagation(); if (isMenuOpen && menuItem === currentSubmenu) { closeDesktopMenu(); } else { openDesktopMenu(menuItem); } }; eventListeners.set(menuItem + “_click”, clickHandler); menuItem.addEventListener(“click”, clickHandler); // Add the same toggle logic to the submenu toggle button const toggleButton = menuItem.querySelector(“.wp-block-navigation-submenu__toggle”); if (toggleButton) { const toggleHandler = function (e) { e.preventDefault(); e.stopPropagation(); if (isMenuOpen && menuItem === currentSubmenu) { closeDesktopMenu(); } else { openDesktopMenu(menuItem); } }; eventListeners.set(toggleButton, toggleHandler); toggleButton.addEventListener(“click”, toggleHandler); } }); // Add hover handlers to custom container to keep it open const containerMouseEnterHandler = function () { if (hoverTimeout) { clearTimeout(hoverTimeout); hoverTimeout = null; } }; const containerMouseLeaveHandler = function () { hoverTimeout = setTimeout(() => { closeDesktopMenu(); }, 200); }; eventListeners.set(customContainer, { containerMouseEnterHandler, containerMouseLeaveHandler }); customContainer.addEventListener(“mouseenter”, containerMouseEnterHandler); customContainer.addEventListener(“mouseleave”, containerMouseLeaveHandler); // Handle click outside to close menu const documentClickHandler = function (e) { if ( isMenuOpen && !customContainer.contains(e.target) && !currentSubmenu?.contains(e.target) ) { closeDesktopMenu(); } }; eventListeners.set(document, documentClickHandler); document.addEventListener(“click”, documentClickHandler); const overlayClickHandler = function () { closeDesktopMenu(); }; eventListeners.set(overlay, overlayClickHandler); overlay.addEventListener(“click”, overlayClickHandler); } // Function to remove all custom event listeners function removeAllEventListeners() { // Clear any pending timeout if (hoverTimeout) { clearTimeout(hoverTimeout); hoverTimeout = null; } eventListeners.forEach((handler, element) => { if (element === document) { document.removeEventListener(“click”, handler); } else if (element === overlay) { overlay.removeEventListener(“click”, handler); } else if (element === customContainer) { customContainer.removeEventListener(“mouseenter”, handler.containerMouseEnterHandler); customContainer.removeEventListener(“mouseleave”, handler.containerMouseLeaveHandler); } else if (typeof element === “string” && element.includes(“_click”)) { // Skip these, they’re handled differently } else if (handler.mouseEnterHandler) { const menuItem = element; menuItem.removeEventListener(“mouseenter”, handler.mouseEnterHandler); menuItem.removeEventListener(“mouseleave”, handler.mouseLeaveHandler); } else { element.removeEventListener(“click”, handler); } }); eventListeners.clear(); } // Function to handle view changes function handleViewChange() { if (isDesktopView()) { setupDesktopBehavior(); } else { // For mobile: completely remove our handlers removeAllEventListeners(); closeDesktopMenu(); } } // Initial setup handleViewChange(); // Handle window resize window.addEventListener(“resize”, function () { handleViewChange(); }); });

Point AI

Powered by AI and perfected by seasoned editors. Every story blends AI speed with human judgment.

EXCLUSIVE

Twitter users can now express their thoughts with voice tweets, only on iOS

Subject(s):

Psst… you’re reading Techpoint Digest

Every day, we handpick the biggest stories, skip the noise, and bring you a fun digest you can trust.

Digest Subscription (In-post)

Twitter has announced a new feature that allows users to tweet audio instead of text.

The audio tweet feature is targeted especially at podcasters, journalists, activists, advertisers, and other creatives that want to literally get their voices out on the platform.

It is also somewhat reminiscent of Orbi, a defunct Nigerian social network that was based solely on 9-second audio micro-posts.

[auto-iframe link=https://techpoint.africa/2015/05/11/orbi-your-9-seconds-voice-note-social-network/embed tag=orbi]

For now, Twitter’s audio tweet feature is only available on a few iOS devices and will be rolled out fully for other iPad and iPhone users in coming weeks. This adds to the number of new tools that have been introduced into the app within the last month — from quoted tweets to the recent ‘test’ feature.

For tweeters with this feature, the ‘record’ option is available along with other tweet formatting options. Currently, audio tweets cannot be edited, and this may not be possible “until the recording needs of users have been figured out,” according to a statement by a member of the product design team.

You would agree that reading a long thread of text can be as tiring and time-consuming as it is to type it. Remember Glory Osei’s 182-tweet thread? That could have been a 15-minute podcast.

Speaking of length, a Twitter voice note can only be a little above two minutes per tweet. That means if the recording gets longer than this, it automatically breaks into an audio tweet thread.

Apart from other reactions trailing this announcement, questioning why Android users are excluded, this feature is not without its shortfalls. While some of these shortfalls are obvious, others will be noticed with time. One of it is inclusiveness.

For an app that has practically been based on texts, a hearing impaired Twitter user may need a subtitle to understand this type of tweet. Perhaps, an upgrade will provide this.

Although the voice feature will allow users to be dynamic with their expressions, there’s a possibility that it might increase trolling, cyberbullying, or hate speech, and this cannot be ignored. Twitter would possibly include a flagging mechanism to handle this in the future.

With the recent trend, users will expect Twitter to continue to pop up more surprising features. If anything, one would have guessed that the social media platform is going through a sort of remodelling.

Follow Techpoint Africa on WhatsApp!

Never miss a beat on tech, startups, and business news from across Africa with the best of journalism.

Follow

Read next