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

SlideMenu: Pass information about levelState #3407

Closed
wolnynick opened this issue Oct 2, 2022 · 1 comment · Fixed by #3186 or #3411
Closed

SlideMenu: Pass information about levelState #3407

wolnynick opened this issue Oct 2, 2022 · 1 comment · Fixed by #3186 or #3411
Assignees
Labels
Type: New Feature Issue contains a new feature or new component request
Milestone

Comments

@wolnynick
Copy link

Describe the feature you would like to see added

Thanks a lot for this feature: #3397, but after thinking a little about this I noted that we can't know when our button with this functionality (onNavigateBack) should be visible.

Your button checks levelState before render:

        const createBackward = () => {
            const className = classNames('p-slidemenu-backward', {
                'p-hidden': levelState === 0
            });

            return (
                <div ref={backward} className={className} onClick={navigateBack}>
                    <span className="p-slidemenu-backward-icon pi pi-fw pi-chevron-left"></span>
                    <span>{props.backLabel}</span>
                </div>
            );
        };

Outside of the component we should have something similar:

useEffect(() => {
   onLevelChange(levelState)
}, [levelState])

or

        const navigateForward = () => {
            setLevelState((prevLevel) => prevLevel + 1);
            onLevelChange(levelState)
        };

        const navigateBack = () => {
            setLevelState((prevLevel) => prevLevel - 1);
            onLevelChange(levelState)
        };

SlideMenu.displayName = 'SlideMenu';
SlideMenu.defaultProps = {
    ...
    onLevelStateChange: null
};

Is your feature request related to a problem?

No response

Describe the solution you'd like

No response

Describe alternatives you have considered

No response

Additional context

No response

@wolnynick wolnynick added Status: Discussion Issue or pull request needs to be discussed by Core Team Type: New Feature Issue contains a new feature or new component request labels Oct 2, 2022
@github-actions github-actions bot added the Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible label Oct 2, 2022
melloware added a commit to melloware/primereact that referenced this issue Oct 2, 2022
@melloware melloware self-assigned this Oct 2, 2022
@melloware melloware removed Status: Discussion Issue or pull request needs to be discussed by Core Team Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible labels Oct 2, 2022
@melloware melloware added this to the 8.6.2 milestone Oct 2, 2022
@melloware
Copy link
Member

I added two things an onNavigate(level: number) callback as well as exposed setLevelState so you can set a level directly. This should solve both this issue and #3398

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: New Feature Issue contains a new feature or new component request
Projects
None yet
2 participants