Custom Context Menu / Custom Right Click Menu in React and NextJS Tutorial

preview_player
Показать описание
In this tutorial we'll take a look at creating a custom context menu / custom right click menu in React, NextJS and Typescript. Creating your own context menu in React is very simple and only takes a couple minutes. The styling of the custom right click menu is left totally up to you, I'll just demonstrate the technical side of things to make it work easily :)

I hope you enjoyed the tutorial and have fun with your custom right click menu!
Рекомендации по теме
Комментарии
Автор

How did you build the markdown editor is this a library?

tekne
Автор

Thank you for this helpful tutorial! I also want context menu to open upward and not downward if there is no space for menu at the bottom. Similarly I want menu to open leftward if there is no space for menu on the right. How to do this?

MohitAtray
Автор

At the end, you forgot to remove onClick on div element. Because of that, your element will close if you click on it. Anyway, thanks about this video. It's been realy helpful

Danterus
Автор

Great video but I'd like to suggest you that when you pass a ref to child or custom hook, make use of forwardRef

carefree_ladka
Автор

instead of position: absolute, it's better to use fixed because the pageX and pageY are relative to the entire page. it will not interfere with the parent elements with position: relative.

aseeruzzaman
Автор

Great job!!! Thank you for useful information👍👍👍

johnconnor
Автор

notice it's better to use clientX and clientY instead pageX and pageY because:
pageX/Y gives the coordinates relative to the <html> element in CSS pixels. clientX/Y gives the coordinates relative to the viewport in CSS pixels.
when u use pageX and pageY when u scroll the page and your context menu was defined on an element of page, mouse target is not accurate on parent

issue example: create a div on page give scroll overflow to main app and set you context and right click on your div and make scroll at the bottom of div when u right click context open far as u scrolled the page from your mouse capture

hshdhdhfh
Автор

Hi Josh, Does this work with nested menus?

zakariya
welcome to shbcf.ru