Skip to content

Fix captions menu not closing on mouseleave in mediaelement player#887

Open
tobias-franke wants to merge 1 commit intovoc:mainfrom
tobias-franke:main
Open

Fix captions menu not closing on mouseleave in mediaelement player#887
tobias-franke wants to merge 1 commit intovoc:mainfrom
tobias-franke:main

Conversation

@tobias-franke
Copy link
Contributor

This PR fixes a regression introduced while addressing Issue #881 (captions not selectable on touch devices).

The Situation

To fix the issue where mobile users could not select subtitles, a setTimeout was added to vendor/assets/javascripts/mediaelement-and-player.js. The intention was to delay the hiding of the menu slightly, giving touch devices enough time to register a click on the menu items before focus was lost.

The Problem

The implementation of this delay introduced a bug. The setTimeout was placed outside the event handler causing the mouseleave and focusout event listeners never getting attached. This had the effect, that the the captions menu would stay visible permanently.

How to reproduce

  1. Load a video page with captions enabled.
  2. Hover over the CC icon to show the captions menu.
  3. Move the mouse cursor away from the CC icon.
  4. The captions menu stays permanently visible instead of becoming invisible.

The Fix

I have moved the setTimeout inside the event handler callback.

  • Fixes the regression: The addEventListener is called immediately, so the mouseleave listener is correctly attached, and the menu closes as expected.
  • Preserves the original fix: The logic inside the handler is delayed by 20ms, ensuring that mobile/touch users still have time to select a caption before the menu hides.

Validation

I tested the changes with a local dev setup on both a desktop and a mobile browser.

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.

1 participant