feat(Popup): show on contextmenu#1524
Conversation
Codecov Report
@@ Coverage Diff @@
## master #1524 +/- ##
==========================================
- Coverage 71.31% 71.22% -0.09%
==========================================
Files 855 857 +2
Lines 7052 7094 +42
Branches 2008 2048 +40
==========================================
+ Hits 5029 5053 +24
- Misses 2017 2035 +18
Partials 6 6
Continue to review full report at Codecov.
|
|
I am afraid that we are overcomplicating Popup with too many things it can do. Hence, make it hard for the consumer to figure out all the API and abilities of the component. |
This PR only adds the possibility to open the popup on right click. It can already open on focus, hover, click and combination of them so I don't think it is a big addition to the API. I agree that |
I agree with @sophieH29 that a separate component makes sense. @jurokapsiar can you please update the description of the PR with the problems and user scenarios we're trying to solve based on what we discussed offline? I did a bit of research and here is what other libraries are doing: 1. Use a context menu
2. Have a select / overflow menu (that we can customize to work for right-click)
Let's take the best out of these and come up with best compromise based on the user scenarios we're trying to solve. |
|
@Bugaa92 we had a discussion offline and the agreement was indeed to create a separate component for the context menu, but to reuse the Popup for that. This PR only includes changes necessary for the Popup, there will be a followup PR with the rest. I updated the description with the reasons. |
packages/react/src/lib/accessibility/Behaviors/Popup/popupBehavior.ts
Outdated
Show resolved
Hide resolved
| trigger?: JSX.Element | ||
|
|
||
| /** Trigger is responsible for being focusable */ | ||
| triggerHandlesFocus?: boolean |
There was a problem hiding this comment.
Jush sharing my thoughts. This prop seems to be only needed to define if set tabindex to trigger or not. Frankly, for me a bit confusing from the prop name what it is for.
If this prop is false, the trigger will be set attribute tabindex=0, what will make it tabbable, nit just focusable.
As one of the options:
- we can have a prop
shouldTriggerBeTabbableand make ittrueby default - Or, utilize attribute
data-is-focusable. If it set to "false" to trigger, inpopupBehaviorcheck it and do not set tabindex. Though it needs proper documentation, but kind of consistency of using it (we use it for FocusZone)
Maybe other folks will have thoughts around that :)
There was a problem hiding this comment.
I like the first option, seems cleaner
There was a problem hiding this comment.
In my opinion the second option is better, because we already have a mechanism for this, why introduce a new one. If we continue with this new pattern, we will start adding tabbable props on different components, and it's not something we want to do...
There was a problem hiding this comment.
But that means that data-is-focusable prop would add data-is-focusable attribute as well as add tabindex. It would make that prop both handled and unhandled, do we really want that?
| attributes: { | ||
| trigger: { | ||
| tabIndex: getAriaAttributeFromProps('tabIndex', props, 0), | ||
| ...(props.triggerHandlesFocus |
There was a problem hiding this comment.
What is the use case of this prop? If this is connected with the 'context' value on the on prop can we use that one instead?
There was a problem hiding this comment.
it's not only related to context value. I have renamed the prop, hopefully it is more clear now.
docs/src/examples/components/Popup/Usage/PopupExampleOnMultiple.shorthand.tsx
Outdated
Show resolved
Hide resolved
|
Just noticed that we have a paragraph on right-click support in documentation, would be great to update it too https://stardust-ui.github.io/react/accessibility#right-click-support |
|
I merged the latest @jurokapsiar can you please check? |
|
@Bugaa92, @layershifter thanks for the review. I have resolved your comments. For your points:
1 I was not able to repro but I will check with you tomorrow to see if it's not version specific behavior - but I checked chrome and FF |
…ui/react into jukapsia/context-popup
|
To fix CI, please update namedExports: {
'node_modules/keyboard-key/src/keyboardKey.js': [
// items
'PageDown',
'PageUp',
]
} |





Often, what appears to be just menu is not only a menu. Below are two examples that are called "Menu" by the component libraries, but are actually combining Menu with other components in a Popup - Semantic UI and Fabric:
There are two use cases for context menu (or ... menu):
It makes sense to allow both and the plan to do that is:
Reasons to reuse Popup in Context menu:
Both create a new surface - intline or portal
Both have trigger element
Both can have similar events opening and closing: click, hover, focus (contextmenu)
Positioning - above, below
Alignment
Click outside to close
Opening children surfaces
Focus trap, auto focus functionality
What is not currently in Popup:
It makes sense to add both of these two and allow to create augumented menus using Popup.
Right click popup cannot be easily repositioned as it is attached to a fixed point (mouse position). There are two ways how the libraries or apps are handling it:
Currently it is easier just to dismiss, but we will add an option to prevent scrolling: #1579