Skip to content

feature: menu group - default expand option #1389

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

Merged
merged 16 commits into from
Oct 27, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion src/components/ui/menu/menuGroup.component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,13 @@ const POSITION_OUTSCREEN: Point = Point.outscreen();
*/
export class MenuGroup extends React.Component<MenuGroupProps, State> {

private initialExpanded: boolean;

constructor(props) {
super(props);
this.initialExpanded = this.props.initialExpanded || false;
}

public state: State = {
submenuHeight: 1,
};
Expand Down Expand Up @@ -114,9 +121,10 @@ export class MenuGroup extends React.Component<MenuGroupProps, State> {

private onSubmenuMeasure = (frame: Frame): void => {
this.setState({ submenuHeight: frame.size.height });
if (this.props.initialExpanded) {
if (this.initialExpanded) {
const expandValue: number = this.expandAnimationValue > 0 ? 0 : this.state.submenuHeight;
this.createExpandAnimation(expandValue, 0).start();
this.initialExpanded = false
}
};

Expand Down Expand Up @@ -181,6 +189,8 @@ export class MenuGroup extends React.Component<MenuGroupProps, State> {
public render(): React.ReactNode {
const { children, ...itemProps } = this.props;

console.log(this.initialExpanded);

return (
<React.Fragment>
<MenuItem
Expand Down