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: ui.menu component #1076

Merged
merged 44 commits into from
Jan 10, 2025
Merged

feat: ui.menu component #1076

merged 44 commits into from
Jan 10, 2025

Conversation

dgodinez-dh
Copy link
Contributor

ui.menu component for deephaven.ui
https://deephaven.atlassian.net/browse/DH-18089
Python, Javascript, and docs.


The `is_open` and `default_open` props on the `menu_trigger` control whether the Menu is open by default. They apply controlled and uncontrolled behavior on the `menu` respectively.

```python
Copy link
Contributor

Choose a reason for hiding this comment

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

I see this example was copied from the Spectrum docs, but it doesn't really seem to showcase what the props do since it behaves the same as if is_open wasn't set at all.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added a text to show the state.

Copy link
Contributor

Choose a reason for hiding this comment

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

Since the description says the props control whether the Menu is open by default, it might be good to initialize the state with ui.use_boolean(True) so that it is open initially.


from deephaven.table import Table, PartitionedTable
from .basic import component_element
from .section import SectionElement, Item
Copy link
Contributor

Choose a reason for hiding this comment

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

There seem to be a number of unused imports in this module.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated

default_selected_keys: SelectionAll | List[Key] | None = None,
on_action: Callable[[Key], None] | None = None,
on_close: Callable[[], None] | None = None,
on_selection_change: Callable[[SelectionAll | List[Key]], None] | None = None,
Copy link
Contributor

Choose a reason for hiding this comment

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

For a lot of dh.ui components we included a conventional on_change prop and deprecated the on_selection_change or comparable prop. Not sure if we decided not to do that for menu. Just calling it out in case we missed it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated

callback(value);
return;
}
callback([...value] as [Key]);
Copy link
Contributor

Choose a reason for hiding this comment

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

The [Key] type suggests a tuple containing a single item. Can ...value contain multiple?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This was a typescript typo elsewhere. I had defined [Key] instead of Key[].

return <DHCMenu {...menuProps} />;
}

Menu.displayName = 'Menu';
Copy link
Contributor

@bmingles bmingles Jan 7, 2025

Choose a reason for hiding this comment

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

No harm in having this here, but I don't think displayName is needed on plain function components since dev tools can derive it from the function name. It is still needed on arrow functions.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed

Copy link
Contributor

@bmingles bmingles left a comment

Choose a reason for hiding this comment

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

Tested examples, and functionality looks good. Left a few comments on docs + minor code suggestions.

@dgodinez-dh dgodinez-dh requested a review from bmingles January 10, 2025 15:32
bmingles
bmingles previously approved these changes Jan 10, 2025
Copy link
Contributor

@bmingles bmingles left a comment

Choose a reason for hiding this comment

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

LGTM

@dgodinez-dh dgodinez-dh removed the request for review from jnumainville January 10, 2025 17:37

## Content

Menu accepts `item` elements as children, each with a `key` prop. Basic usage of `menu`, seen in the example above, shows multiple items populated with a string.
Copy link
Contributor

Choose a reason for hiding this comment

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

When you say "Menu" do you really mean menu? Or "Menus accept / A menu accepts"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Change to:
A menu accepts

plugins/ui/docs/components/menu.md Outdated Show resolved Hide resolved
plugins/ui/docs/components/menu.md Outdated Show resolved Hide resolved
plugins/ui/docs/components/menu.md Outdated Show resolved Hide resolved
plugins/ui/docs/components/menu.md Outdated Show resolved Hide resolved
plugins/ui/docs/components/menu_trigger.md Outdated Show resolved Hide resolved
plugins/ui/docs/components/menu_trigger.md Outdated Show resolved Hide resolved
plugins/ui/docs/components/menu_trigger.md Outdated Show resolved Hide resolved
plugins/ui/docs/components/menu_trigger.md Outdated Show resolved Hide resolved
@dgodinez-dh dgodinez-dh merged commit cf23da1 into deephaven:main Jan 10, 2025
18 checks passed
@dgodinez-dh dgodinez-dh deleted the dag_Menu branch January 10, 2025 21:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants