{"id":16447241,"url":"https://github.com/junekelly/cm6-contextmenu-tooltip-problem","last_synced_at":"2026-05-13T01:06:06.305Z","repository":{"id":145904197,"uuid":"460869493","full_name":"JuneKelly/cm6-contextmenu-tooltip-problem","owner":"JuneKelly","description":null,"archived":false,"fork":false,"pushed_at":"2022-02-18T14:12:25.000Z","size":399,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-26T11:44:14.344Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/JuneKelly.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-02-18T13:45:12.000Z","updated_at":"2022-02-18T13:45:36.000Z","dependencies_parsed_at":null,"dependency_job_id":"8252d999-e9a5-4b35-b1d3-9154a71c696c","html_url":"https://github.com/JuneKelly/cm6-contextmenu-tooltip-problem","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/JuneKelly/cm6-contextmenu-tooltip-problem","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JuneKelly%2Fcm6-contextmenu-tooltip-problem","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JuneKelly%2Fcm6-contextmenu-tooltip-problem/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JuneKelly%2Fcm6-contextmenu-tooltip-problem/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JuneKelly%2Fcm6-contextmenu-tooltip-problem/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/JuneKelly","download_url":"https://codeload.github.com/JuneKelly/cm6-contextmenu-tooltip-problem/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JuneKelly%2Fcm6-contextmenu-tooltip-problem/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32963180,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-12T23:30:32.555Z","status":"ssl_error","status_checked_at":"2026-05-12T23:30:18.191Z","response_time":102,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-11T09:50:08.591Z","updated_at":"2026-05-13T01:06:06.282Z","avatar_url":"https://github.com/JuneKelly.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# CM6, contextmenu/tooltip problem\n\n## The setup\n\n- A CodeMirror 6 editor\n- with a `tooltip`, which shows a message above some position in the document\n- An event handler for `contextmenu`, which dispatches an effect to show the message tooltip\n  when the user right-clicks on the editor.\n\n\n## The problem\n\nIn firefox, this works correctly. The message tooltip is shown on right-click, and \ndismissed when we click elsewhere in the editor.\n\n![](images/counter.png)\n\nIn chrome, this does not work consistently. Very often, the first click does not show \nthe tooltip, and we need to right-click a second time to make it appear.\n\nAlso, in chrome, if we right-click a blank line, we seem to always get the tooltip message.\n\nIt seems that something is wrong in the interaction between chrome, the contextmenu event,\nand the way CM6 handles tooltips.\n\n## Gifs\n\n### In Firefox (consistent behaviour):\n\n![](./images/cm6-firefox.gif)\n\n\n### In Chrome (inconsistent behaviour):\n\n![](./images/cm6-chrome.gif)\n\n\n## Clues\n\nWe have several log messages to help us debug this issue.\nOne interesting pattern we see in chrome is that when the contextmenu event fires,\nthe `compute()` function seems to get called *twice* in rapid succession. In \nthe first call, we see the tooltip object as we expect, but in the second call,\nwe see a `null`. This may account for how the tooltip is not shown.\n\n\n## Work-around\n\nIf we add a second event handler, for `mouseup`, with a filter on `button === 2`, we \ncan make this behave consistently across both browsers, at the expense of calling the \nrelevant code twice.\n\nSee commented-out code in `index.js`.\n\nNotably, we need *both* handlers to make it work consistently. Either of them on their own is not sufficient.\n\n\n## To run:\n\n``` sh\nnpm ci\n\nnpm start\n```\n\nSee `index.html`, and `index.js` for code.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjunekelly%2Fcm6-contextmenu-tooltip-problem","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjunekelly%2Fcm6-contextmenu-tooltip-problem","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjunekelly%2Fcm6-contextmenu-tooltip-problem/lists"}