Skip to content

Fix notepad menu dropdown disappearing when moving mouse to select options#40

Draft
Copilot wants to merge 3 commits intomainfrom
copilot/fix-4ca1942f-5c31-4ee2-a9a0-bbbeb84e06e5
Draft

Fix notepad menu dropdown disappearing when moving mouse to select options#40
Copilot wants to merge 3 commits intomainfrom
copilot/fix-4ca1942f-5c31-4ee2-a9a0-bbbeb84e06e5

Conversation

Copy link
Contributor

Copilot AI commented Sep 29, 2025

Problem

The File and Edit menus in the Notepad application had a critical usability issue where dropdown menus would immediately disappear when users moved their mouse from the menu item down to select an option. This made it impossible to actually use the menu options like "Save" and "Clear".

Root Cause

The issue was caused by the onmouseleave event handler on the menu items calling hideNotepadMenu() immediately when the mouse left the menu item area, before users could reach the dropdown options.

// Before: Menu disappeared immediately on mouseleave
'<span class="notepad-menu" onmouseleave="hideNotepadMenu()">File</span>'

Solution

Implemented a timeout-based approach that allows smooth mouse movement between menu items and their dropdown options:

  1. Added 150ms delay before hiding menus to allow natural mouse movement
  2. Enhanced dropdown containers with their own mouse event handlers to cancel/trigger hide timeouts
  3. Improved function architecture with separate immediate and delayed hide functions
// After: Proper timeout-based hiding with dropdown event handling
function hideNotepadMenu() {
  if (notepadMenuTimeout) {
    clearTimeout(notepadMenuTimeout);
  }
  notepadMenuTimeout = setTimeout(() => {
    hideNotepadMenuImmediate();
    notepadMenuTimeout = null;
  }, 150);
}

// Dropdown containers can now cancel the hide timeout
'<div id="notepad-file-menu" onmouseenter="cancelHideNotepadMenu()" onmouseleave="hideNotepadMenu()">'

Key Changes

  • Enhanced menu functions: Added cancelHideNotepadMenu() and separated immediate vs delayed hiding
  • Dropdown event handlers: Added onmouseenter and onmouseleave to dropdown containers
  • Timeout management: Proper cleanup and cancellation of hide timeouts
  • Preserved existing behavior: Menu items still highlight and menus still hide when appropriate

Testing

Verified comprehensive user interaction scenarios:

  • ✅ Menus appear correctly on hover
  • ✅ Menus stay visible when moving mouse to dropdown options
  • ✅ Menus hide appropriately after leaving both menu item and dropdown
  • ✅ Menu switching works correctly between File and Edit
  • ✅ Clicking menu options works and properly closes menus

Screenshot

Working Notepad Menu

The fix maintains the original Windows 98-style behavior while resolving the usability issue that prevented users from actually selecting menu options.

Original prompt

This section details on the original issue you should resolve

<issue_title>File and Edit menu on Notepad does not work correctly</issue_title>
<issue_description>When I hover over File or Edit, the submenu appears, but the submenu disappears once you move the mouse down to select an option.</issue_description>

Comments on the Issue (you are @copilot in this section)

Fixes #39

💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.

Copilot AI and others added 2 commits September 29, 2025 03:48
Co-authored-by: jcleigh <12815554+jcleigh@users.noreply.github.com>
Co-authored-by: jcleigh <12815554+jcleigh@users.noreply.github.com>
Copilot AI changed the title [WIP] File and Edit menu on Notepad does not work correctly Fix notepad menu dropdown disappearing when moving mouse to select options Sep 29, 2025
Copilot AI requested a review from jcleigh September 29, 2025 03:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

File and Edit menu on Notepad does not work correctly

2 participants