Ask Your Question
2

How to stop the context menu from appearing on the headers of details list groups in fluentui?

asked 2022-10-31 11:00:00 +0000

lakamha gravatar image

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
3

answered 2023-01-23 12:00:00 +0000

qstack gravatar image

You can prevent the context menu from appearing on the headers of details list groups in fluentui by setting the "data-is-focusable" attribute to "true" on the header element. This will ensure that the header element does not have focus and will not trigger the context menu on right-click.

For example, in React JSX, you can add the "data-is-focusable" attribute to the header element as follows:

<DetailsList
  items={items}
  groups={groups}
  onRenderHeader={(props, defaultRender) => {
    return (
      <div
        data-is-focusable="true" // Add this attribute to prevent context menu
        role="button"
        onClick={() => {
          // Handle click event
        }}
      >
        {defaultRender(props)}
      </div>
    );
  }}
/>

Note that setting "data-is-focusable" to false or removing it entirely on a header element will allow the context menu to appear on right-click.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss

Add Answer


Question Tools

Stats

Asked: 2022-10-31 11:00:00 +0000

Seen: 9 times

Last updated: Jan 23 '23