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

feat: add menu component #28583

Merged
merged 1 commit into from
Nov 3, 2023
Merged

feat: add menu component #28583

merged 1 commit into from
Nov 3, 2023

Conversation

KelvinOm
Copy link
Collaborator

@KelvinOm KelvinOm commented Nov 2, 2023

Description

Add WDS menu component

PR fixes following issue(s)

Fixes #28392

Media

2023-11-02.22.26.28_compressed.mp4

Type of change

  • New feature (non-breaking change which adds functionality)

Testing

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Also list any relevant details for your test configuration.
Delete anything that is not relevant

  • Manual
  • JUnit
  • Jest
  • Cypress

Checklist:

Dev activity

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • PR is being merged under a feature flag

@github-actions github-actions bot added App Viewers Pod This label assigns issues to the app viewers pod WDS team Anvil POD Issue related to Anvil project Enhancement New feature or request labels Nov 2, 2023
@KelvinOm KelvinOm added skip-changelog Adding this label to a PR prevents it from being listed in the changelog skip-docs skip-testPlan Does not require QA intervention or approval process skip-documentation To avoid commenting the reminder about the documentation update. labels Nov 2, 2023
const labelAndContextualHelp = (
<div data-field-label-wrapper="">
{Boolean(label) && (
const labelAndContextualHelp =
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@jsartisan Changes in order not to add excessive div.

Copy link
Contributor

Choose a reason for hiding this comment

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

I have refactored some of the code in the field in the currency input widget PR.


<Canvas>
<Story name="Menu example">
<Menu
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@dhruvikn @jsartisan Pay attention to how the API is implemented here. This may be somewhat unexpected. Inheriting the implementation from Spectrum.

Copy link
Contributor

Choose a reason for hiding this comment

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

The API looks good to me. But we can't make nested menu right with this?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We can do something like this (see pict.) Taras said that this is enough for now. Spectrum also developing such functionality.

Anyway, we can redo the implementation for floating-ui. But I have concerns about how they work with touch devices.

Снимок экрана 2023-11-03 в 09 22 59

Copy link
Contributor

Choose a reason for hiding this comment

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

Ok cool then.

});

return cloneElement(children, {
onPress: () => {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

So far we can only work with buttons. I'll think about how to make the correct implementation for other components.


import type { PopoverProps } from "./types";

const DEFAULT_POPOVER_OFFSET = 10;
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@jsartisan We have to add tokens here. In the tooltip too.

>
{cloneChildren(children)}
</div>
<ButtonGroupContext.Provider value={{ color, variant }}>
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Changed the implementation since now ButtonGroupItem may not be a direct children since we can, for example, use the Menu inside ButtonGroup now.

@@ -57,6 +57,8 @@ module.exports = {
typescript: {
reactDocgen: "react-docgen-typescript",
reactDocgenTypescriptOptions: {
propFilter: (prop) =>
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Fix for ArgsTable.

@KelvinOm
Copy link
Collaborator Author

KelvinOm commented Nov 2, 2023

/ok-to-test

Copy link

github-actions bot commented Nov 2, 2023

Tests running at: https://github.com/appsmithorg/appsmith/actions/runs/6738003497.
Workflow: Appsmith External Integration Test Workflow.
Commit: ``.
PR: 28583.

Copy link

github-actions bot commented Nov 2, 2023

Workflow run: https://github.com/appsmithorg/appsmith/actions/runs/6738003497.
Commit: ``.
Cypress dashboard: Click here!
The following are new failures, please fix them before merging the PR:

  1. cypress/e2e/Regression/ClientSide/Git/ExistingApps/v1.9.24/DSCrudAndBindings_Spec.ts

  2. cypress/e2e/Regression/ClientSide/Widgets/Multiselect/Multi_Select_Tree_spec.js
  3. cypress/e2e/Regression/ServerSide/QueryPane/S3_2_spec.ts
To know the list of identified flaky tests - Refer here

const labelAndContextualHelp = (
<div data-field-label-wrapper="">
{Boolean(label) && (
const labelAndContextualHelp =
Copy link
Contributor

Choose a reason for hiding this comment

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

I have refactored some of the code in the field in the currency input widget PR.

const { className, item, state } = props;
const ref = React.useRef(null);
const { isDisabled, isFocused, isPressed, isSelected, menuItemProps } =
useMenuItem({ key: item.key }, state, ref);
Copy link
Contributor

Choose a reason for hiding this comment

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

The problem with spectrum menu hook is we can't make nested menus :/ That might be a requirement for ADS ( if ADS ever plans to use our headless component )

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Answered here


<Canvas>
<Story name="Menu example">
<Menu
Copy link
Contributor

Choose a reason for hiding this comment

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

The API looks good to me. But we can't make nested menu right with this?

import type { ReactNode } from "react";
import type { Dispatch, SetStateAction } from "react";
import type { usePopover } from "./usePopover";
import type { Placement } from "@floating-ui/react";
Copy link
Contributor

Choose a reason for hiding this comment

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

I feel weird about mix of spectrum and floating-ui 🤔

Copy link
Contributor

Choose a reason for hiding this comment

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

What does hook spectrum's menu do? do they just add aria props or do they also add some functionality/events on the components.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

They provide accessibility support, handle keyboard events, control focus, and provide support for touch devices. Because of the last point, the choice fell on spectrum instead of floating-ui.

<Menu {...args} disabledKeys={["cut"]} onAction={(key) => console.log(key)}>
<Button>My trigger</Button>
<MenuList>
<Item key="copy">Copy</Item>
Copy link
Contributor

Choose a reason for hiding this comment

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

we might need a way to add startIcon and endIcon to the Menu Item

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I will add it as part of another ticket.

@@ -377,6 +377,7 @@
"@blueprintjs/core@^3.47.0": "patch:@blueprintjs/core@npm%3A3.47.0#./.yarn/patches/@blueprintjs-core-npm-3.47.0-a5bc1ea927.patch",
"@blueprintjs/icons": "3.22.0",
"@types/react": "^17.0.2",
"postcss": "8.4.31"
"postcss": "8.4.31",
"@react-types/shared": "3.19.0"
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We have to update all dependencies and fix types conflicts.

Снимок экрана 2023-11-02 в 22 48 17

cc @jsartisan

Copy link

github-actions bot commented Nov 3, 2023

Workflow run: https://github.com/appsmithorg/appsmith/actions/runs/6738003497.
Commit: ``.
Cypress dashboard url: Click here!
All cypress tests have passed 🎉🎉🎉

@KelvinOm KelvinOm merged commit 5dd2900 into release Nov 3, 2023
19 of 20 checks passed
@KelvinOm KelvinOm deleted the feat/wds-menu branch November 3, 2023 09:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Anvil POD Issue related to Anvil project App Viewers Pod This label assigns issues to the app viewers pod Enhancement New feature or request skip-changelog Adding this label to a PR prevents it from being listed in the changelog skip-docs skip-documentation To avoid commenting the reminder about the documentation update. skip-testPlan Does not require QA intervention or approval process WDS team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Create WDS Menu component
3 participants