Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Topology: Prevent user action on disabled context menu items #3695

Merged

Conversation

jeff-phillips-18
Copy link
Member

@openshift-ci-robot openshift-ci-robot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Dec 5, 2019
@openshift-ci-robot openshift-ci-robot added the component/dev-console Related to dev-console label Dec 5, 2019
Comment on lines 29 to 44
const KebabContextMenuItemConnected = (
props: kebabContextMenuItemProps & { impersonate: string },
) => {
const { option, impersonate } = props;
const isAllowed = useAccessReview(option.accessReview, impersonate);
return (
<ContextMenuItem
className="odc2-topology-context-menu__kebab-wrapper"
key={option.label}
onClick={() => onKebabOptionClick(option)}
isDisabled={option.isDisabled || !isAllowed}
>
<KebabItem option={option} onClick={null} />
</ContextMenuItem>
);
};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if you use the PF4 DropdownContext like this:

const createMenuItem = (option: KebabOption) => (
  <DropdownContext.Consumer key={option.label}>
    {({ onSelect }) => (
      <KebabItem
        option={option}
        onClick={() => {
          onKebabOptionClick(option);
          onSelect();
        }}
      />
    )}
  </DropdownContext.Consumer>
);

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The issue is that the KebabItem changes once the accessReview is retrieved. The context menu is getting a ref from the KebabItem and saving it away. Since the KebabItem changes the saved ref is no longe valid and setting focus and key handlers to it is useless.

Using the wrapper ContextMenuItem causes the ref to remain constant and focus and key handlers then work correctly.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated such that the kebab item does not change once the access review is retrieved simplifying and unnesting!

@openshift-ci-robot openshift-ci-robot added the component/core Related to console core functionality label Dec 6, 2019
@jeff-phillips-18
Copy link
Member Author

/retest

@christianvogt
Copy link
Contributor

/lgtm
/approve

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Dec 11, 2019
@openshift-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: christianvogt, jeff-phillips-18

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci-robot openshift-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Dec 11, 2019
@jeff-phillips-18
Copy link
Member Author

/retest

@openshift-bot
Copy link
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

4 similar comments
@openshift-bot
Copy link
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-bot
Copy link
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-bot
Copy link
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-bot
Copy link
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-merge-robot openshift-merge-robot merged commit 99ee853 into openshift:master Dec 12, 2019
@spadgett spadgett added this to the v4.4 milestone Dec 16, 2019
@jeff-phillips-18 jeff-phillips-18 deleted the disabled-context branch December 2, 2020 13:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. component/core Related to console core functionality component/dev-console Related to dev-console lgtm Indicates that a PR is ready to be merged. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants