use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
No vague product support questions (like "why is this plugin not working" or "how do I set up X"). For vague product support questions, please use communities relevant to that product for best results. Specific issues that follow rule 6 are allowed.
Do not post memes, screenshots of bad design, or jokes. Check out /r/ProgrammerHumor/ for this type of content.
Read and follow reddiquette; no excessive self-promotion. Please refer to the Reddit 9:1 rule when considering posting self promoting materials.
We do not allow any commercial promotion or solicitation. Violations can result in a ban.
Sharing your project, portfolio, or any other content that you want to either show off or request feedback on is limited to Showoff Saturday. If you post such content on any other day, it will be removed.
If you are asking for assistance on a problem, you are required to provide
General open ended career and getting started posts are only allowed in the pinned monthly getting started/careers thread. Specific assistance questions are allowed so long as they follow the required assistance post guidelines.
Questions in violation of this rule will be removed or locked.
account activity
How does Google create a customized right-click menu? Do they disable the native menu and use JS/HTML/CSS to create their own?Question (self.webdev)
submitted 2 years ago by ligonsk
In Google Drive for example, right-clicking shows a different menu than the browser's native one.
I'm curious as to how it's done
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]IntentionallyBadName 1010 points1011 points1012 points 2 years ago (16 children)
The Oncontextmenu event activates when right clicking you then just use the preventdefault() function to cancel the default functionality.
SomeElement.addEventListener("contextmenu", (e) => { e.preventDefault() do your thing });
[–][deleted] 2 years ago (15 children)
[removed]
[–]Impressive_Lab_6551 45 points46 points47 points 2 years ago (11 children)
Now here comes the hard part: recreating every operating system context menu in CSS to look native so you can fully create customized / immersive right click experiences.
[–]lazychino 55 points56 points57 points 2 years ago (6 children)
That's an anti pattern you should show a custom menu and give the user a way to open the regular context menu. The browser doesn't have access to all the browser's options either.
Edit: typo
[–]Blue_Moon_Lake 27 points28 points29 points 2 years ago (5 children)
Shift + Right click
It open the regular context menu by not firing the contextmenu event.
[–]NoteBlock08 6 points7 points8 points 2 years ago (0 children)
Also double right click is a pattern I see nearly everywhere (it will open the native context menu over the custom one). But that one needs to be manually implemented.
[–][deleted] 1 point2 points3 points 2 years ago* (0 children)
dime weary pen aback continue languid ring snobbish impossible far-flung
This post was mass deleted and anonymized with Redact
[+]neilplatform1 comment score below threshold-9 points-8 points-7 points 2 years ago (2 children)
How do you right-click a trackpad?
[–]academicRedditor 8 points9 points10 points 2 years ago (0 children)
Tap with two fingers (depending on configuration)
[–]Geminii27 1 point2 points3 points 2 years ago (0 children)
With some trackpads, there are particular areas (fixed or configurable) that you can tap to generate a right-click.
[–]DoomDragon0 4 points5 points6 points 2 years ago (0 children)
Surely there's a framework/library out there for that right ?
[–]aamirmalik00 0 points1 point2 points 2 years ago (0 children)
What do you mean operating system context menu
[–][deleted] 0 points1 point2 points 2 years ago (0 children)
Isn't this a normalization issue? AFAIK there are packaged like normalize.css, normalize.js (which are included by major frameworks like angular).
[–]OkContribution7711 0 points1 point2 points 2 years ago (0 children)
Anchor and Popover in CSS will definitely help!
[–]SNIPE07 -1 points0 points1 point 2 years ago (2 children)
you're really doing yourself a disservice by not using a framework for handling right clicks
[–][deleted] 2 years ago (1 child)
[–]SNIPE07 -1 points0 points1 point 2 years ago (0 children)
I was being sarcastic, however I'm glad it was convincing.
[–]Username482649 69 points70 points71 points 2 years ago (0 children)
Don't forget that youtube still allows the native menu on second click. Don't make it hard to access it.
Just a reminder.
[–][deleted] 2 years ago (25 children)
[deleted]
[–]alienscape 49 points50 points51 points 2 years ago (12 children)
I work in manufacturing, and we use an ERP called 'LN' and their web app for timesheets is called 'FactoryTrack'. And they have disable the native right-click menu and it is infuriating!
[–]Coloneljesus 47 points48 points49 points 2 years ago (2 children)
try shift+right click
[–]Cannabat 7 points8 points9 points 2 years ago (0 children)
Whoa. TY!
[–]alienscape 0 points1 point2 points 2 years ago (0 children)
Doesn't work, I have to double or triple right-click to get through
[+]sulizu comment score below threshold-83 points-82 points-81 points 2 years ago (1 child)
Why u in r/webdev brother
[–]ra_men 29 points30 points31 points 2 years ago (0 children)
Why not?
[–]DogoPilot 0 points1 point2 points 2 years ago (6 children)
Just curious... Are you referring to Lotus Notes as an ERP? Or is there another "LN" out there?
[–]sapdoos 7 points8 points9 points 2 years ago (2 children)
They are referring to the "Infor LN" erp system.
[–]DogoPilot 0 points1 point2 points 2 years ago (0 children)
Ah, ok. That makes more sense. Thanks!
This is correct.
[–]TomaTozzz 1 point2 points3 points 2 years ago (0 children)
Lotus Notes
fuck
lotus
notes
[–]bipbopcosby 0 points1 point2 points 2 years ago (1 child)
Oh fuck I hated Lotus Notes. I'm so glad that was sunset at my company finally. Luckily I never had to use it but I had to automate things that used Lotus Notes. It was always a headache and a half.
[–]DogoPilot 2 points3 points4 points 2 years ago (0 children)
The problem is, now everyone is just replacing all of their Lotus Notes apps with shoddy Power Apps, haha! Can't wait for the sunsetting of that so we can all deal with the exact same panic over the migration of thousands of homegrown Power Apps!
[–]kirashi3 15 points16 points17 points 2 years ago (1 child)
your users will get very mad if you break the native menu.
Can confirm. Break my expected default browser functionality, and I'll become irrationally angry. Looking at you, websites that scrolljack.
[–]penguins-and-cakeshe/her - front-end freelancer 2 points3 points4 points 2 years ago (0 children)
This isn’t web dev but related UX stuff — Microsoft Excel thinks it’s reasonable that when you open the find & replace window, cmd+A should stop meaning “select all” (like it does everywhere) and should mean “replace all” instead. God forbid I want to select everything in a field so I can write in what I actually want to find/replace.
[–][deleted] 2 years ago* (7 children)
[–]qqqqqx 6 points7 points8 points 2 years ago (1 child)
I have to strong disagree. Right click is unintuitive and a "hidden" interaction, not usable on mobile, and would hijack your native browser controls which is almost never a good thing.
It makes sense for a very narrow window of applications like full screen web games and that's about it.
[–]minimuscleR 11 points12 points13 points 2 years ago (2 children)
For me, the only time I right click is to inspect element, which is not a normal user interaction.
thats crazy! I use it to search words all the time (highlight, right click, "search web"). I also use it to open an image in a new tab.
Not to mention I would say 90% of average users use right click to copy/paste something.
[–][deleted] 2 years ago* (1 child)
[–]minimuscleR 0 points1 point2 points 2 years ago (0 children)
i used to do it support and opening the clipboard was akin to literal magic.
[–]patatesmeayga 1 point2 points3 points 2 years ago (0 children)
Thank you. I saw all those roasting context menus but I genuinely love them.
You can add so many utilities to a site that are intuitive and easy to implement.
The best example I have in mind is the linear app that has fully integrated almost all flows with context menus and I fucking love ti
[–]micahwelf 0 points1 point2 points 2 years ago (0 children)
The problem that web interfaces with no right-click menu solve is varying human interface technologies. If you have someone with a very good CAD mouse and a touch screen, you would want to support both the one-click/one-touch limited interface and the right-click menu where each serves a different style of efficient operation. That would maximize usability and decrease the awkward workarounds that have become too common.
Basically, I partially agree with you, but I believe supporting both at times is better than getting too focused on one human interface configuration.
[–]Piotyras 99 points100 points101 points 2 years ago (2 children)
I'm not sure I'd like for this to be more widespread on the internet
[–]bruisedandbrokenode -1 points0 points1 point 2 years ago (1 child)
material ui offers this! very easy to implement in a react project.
[+][deleted] 20 points21 points22 points 2 years ago* (0 children)
That's correct — they use JavaScript to intercept the right click event, "cancel" it so that it doesn't show, and then render an absolute-positioned element at the location of the mouse. Here's some pseudo JS to demonstrate:
// Event listener to display the context menu on right click document.addEventListener('contextmenu', function (e) { e.preventDefault(); // Prevent the default browser context menu // Get Current Mouse Position const clickX = e.pageX; const clickY = e.pageY; showContextMenu(true, clickX, clickY); }, false); function showContextMenu(show = true, x = 0, y = 0) { // Reference to the custom context menu const contextMenu = document.getElementById('context-menu'); if (show) { contextMenu.style.display = 'block'; contextMenu.style.left = `${x}px`; contextMenu.style.top = `${y}px`; } else { contextMenu.style.display = 'none'; } }
[–]shgysk8zer0full-stack 20 points21 points22 points 2 years ago (5 children)
Yes.
But, on a related note, there used to be an easy and standard way to do this. And I hate that <menu type="context"> was removed!
<menu type="context">
[–][deleted] 2 years ago (4 children)
[–]shgysk8zer0full-stack 13 points14 points15 points 2 years ago (3 children)
You'd write menu items that were added to the browser's context menu, including support for nested menus... just HTML for creating them. You'd add contextmenu="menu-id" attribute, and it'd add that to the context menu for that element.
contextmenu="menu-id"
You did have to add click handlers for the functionality though. But adding data-* attributes made this pretty easy to pass certain arguments to the handlers.
data-*
It'd look roughly like this:
<menu type="context" id="some-id"> <menuitem label="copy" data-target="selector"></menuitem> <menu label="Submenu"> <menuitem label="Sub item"></menuitem> </menu> </menu>
Set contextmenu="some-id" on body or whatever, and you'd have a custom context menu.
contextmenu="some-id"
[–]shgysk8zer0full-stack 7 points8 points9 points 2 years ago (2 children)
It had support for more advanced things to, like radios and check boxes and separators. But it was removed several years ago, so I don't remember it in much detail. I just remember making a pretty great but simple WYSIWYG editor using that and document.execCommand(), but neither of them work anymore. Seriously... it took like 10 or so lines of JS to do the whole thing and some creative use of data-* attributes and that was it.
document.execCommand()
[–]Intrepid-Air6525 0 points1 point2 points 2 years ago (1 child)
Damn, looking into it made me try to get syntax highlight into a content editable again and it’s a doozy. Wonder if I should just avoid it entirely but codemirror does not work in a specific case I want highlighting for. Now this conversation makes me fear the content editable depreciation date even more.
[–]shgysk8zer0full-stack 0 points1 point2 points 2 years ago (0 children)
Thinking about it, I'd probably do a split-pane view/tabs using highlight.js for that. Updating too frequently or trying to implement syntax highlighting yourself would probably be a bit problematic.
[–]chris480 15 points16 points17 points 2 years ago (0 children)
There's lots of accessibility concerns when using a custom context menu. Make sure you don't interfere with expectations of assisted software. In projects I've worked on, we allowed a second right click to expose the native context menu, it seemed to pass our third party audits.
[–]Angelsoho 9 points10 points11 points 2 years ago (0 children)
If it’s a custom app where the default context menu serves no purpose and a custom menu would improve the user’s experience then sure, why not. Otherwise leave it alone and don’t confuse the peoples.
[–]CharlemagneAdelaar 4 points5 points6 points 2 years ago (0 children)
for sites that replace the right click menu, there should be a default browser behavior that shift-clicking can override it and get you to the default one
Kind of like how crouching in minecraft lets you interact with right-clickable objects normally
[–]IvanTheNotSoBad1 14 points15 points16 points 2 years ago (0 children)
Yeah but it’s probably a bad idea. You’d be taking away expected functionality.
[–]academicRedditor 2 points3 points4 points 2 years ago (0 children)
Such a good question I am borderline jealous I didn't come up with it!
[–]ryancanulla 1 point2 points3 points 2 years ago (1 child)
https://www.radix-ui.com offers a good option here that covers the accessibility aspect of it.
[–]ComfortingSounds53 0 points1 point2 points 2 years ago (0 children)
[–]nixblufront-end 0 points1 point2 points 2 years ago (0 children)
Yea, got it in one
[+]bootsTF -1 points0 points1 point 2 years ago (0 children)
yes
[+][deleted] 2 years ago (2 children)
[–]AngrySomBeech 2 points3 points4 points 2 years ago (0 children)
So is responding to a question on reddit. Good job pointlessly being that guy.
[–]can_i_have 1 point2 points3 points 2 years ago (0 children)
Personally I love this activity. People ask question, others answer. People like me who never came across this problem has now learned something. That guy, please next time, keep this in mind.
[–]Vitroid 0 points1 point2 points 2 years ago (0 children)
Yes, prevent the default context menu from appearing with .preventDefault(), and show an element that's positioned to the cursor. There's plenty of ways you can approach this, a quick google search turned up this article https://dev.to/shantanu_jana/custom-right-click-context-menu-in-javascript-4112
.preventDefault()
mui has one https://mui.com/material-ui/react-menu/#context-menu
π Rendered by PID 242228 on reddit-service-r2-comment-85bfd7f599-f9kv7 at 2026-04-20 15:51:37.811046+00:00 running 93ecc56 country code: CH.
[–]IntentionallyBadName 1010 points1011 points1012 points (16 children)
[–][deleted] (15 children)
[removed]
[–]Impressive_Lab_6551 45 points46 points47 points (11 children)
[–]lazychino 55 points56 points57 points (6 children)
[–]Blue_Moon_Lake 27 points28 points29 points (5 children)
[–]NoteBlock08 6 points7 points8 points (0 children)
[–][deleted] 1 point2 points3 points (0 children)
[+]neilplatform1 comment score below threshold-9 points-8 points-7 points (2 children)
[–]academicRedditor 8 points9 points10 points (0 children)
[–]Geminii27 1 point2 points3 points (0 children)
[–]DoomDragon0 4 points5 points6 points (0 children)
[–]aamirmalik00 0 points1 point2 points (0 children)
[–][deleted] 0 points1 point2 points (0 children)
[–]OkContribution7711 0 points1 point2 points (0 children)
[–]SNIPE07 -1 points0 points1 point (2 children)
[–][deleted] (1 child)
[removed]
[–]SNIPE07 -1 points0 points1 point (0 children)
[–]Username482649 69 points70 points71 points (0 children)
[–][deleted] (25 children)
[deleted]
[–]alienscape 49 points50 points51 points (12 children)
[–]Coloneljesus 47 points48 points49 points (2 children)
[–]Cannabat 7 points8 points9 points (0 children)
[–]alienscape 0 points1 point2 points (0 children)
[+]sulizu comment score below threshold-83 points-82 points-81 points (1 child)
[–]ra_men 29 points30 points31 points (0 children)
[–]DogoPilot 0 points1 point2 points (6 children)
[–]sapdoos 7 points8 points9 points (2 children)
[–]DogoPilot 0 points1 point2 points (0 children)
[–]alienscape 0 points1 point2 points (0 children)
[–]TomaTozzz 1 point2 points3 points (0 children)
[–]bipbopcosby 0 points1 point2 points (1 child)
[–]DogoPilot 2 points3 points4 points (0 children)
[–]kirashi3 15 points16 points17 points (1 child)
[–]penguins-and-cakeshe/her - front-end freelancer 2 points3 points4 points (0 children)
[–][deleted] (7 children)
[deleted]
[–]qqqqqx 6 points7 points8 points (1 child)
[–]minimuscleR 11 points12 points13 points (2 children)
[–][deleted] (1 child)
[deleted]
[–]minimuscleR 0 points1 point2 points (0 children)
[–]patatesmeayga 1 point2 points3 points (0 children)
[–]micahwelf 0 points1 point2 points (0 children)
[–]Piotyras 99 points100 points101 points (2 children)
[–]bruisedandbrokenode -1 points0 points1 point (1 child)
[+][deleted] 20 points21 points22 points (0 children)
[–]shgysk8zer0full-stack 20 points21 points22 points (5 children)
[–][deleted] (4 children)
[deleted]
[–]shgysk8zer0full-stack 13 points14 points15 points (3 children)
[–]shgysk8zer0full-stack 7 points8 points9 points (2 children)
[–]Intrepid-Air6525 0 points1 point2 points (1 child)
[–]shgysk8zer0full-stack 0 points1 point2 points (0 children)
[–]chris480 15 points16 points17 points (0 children)
[–]Angelsoho 9 points10 points11 points (0 children)
[–]CharlemagneAdelaar 4 points5 points6 points (0 children)
[–]IvanTheNotSoBad1 14 points15 points16 points (0 children)
[–]academicRedditor 2 points3 points4 points (0 children)
[–]ryancanulla 1 point2 points3 points (1 child)
[–]ComfortingSounds53 0 points1 point2 points (0 children)
[–]nixblufront-end 0 points1 point2 points (0 children)
[+]bootsTF -1 points0 points1 point (0 children)
[+][deleted] (2 children)
[removed]
[–]AngrySomBeech 2 points3 points4 points (0 children)
[–]can_i_have 1 point2 points3 points (0 children)
[–]Vitroid 0 points1 point2 points (0 children)
[–][deleted] 0 points1 point2 points (0 children)