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

CascadeSelect: dropdown container creates scrolls in page instead of list container #2229

Closed
davidbejarcaceres opened this issue Aug 3, 2021 · 7 comments · Fixed by #5681
Assignees
Labels
Type: Enhancement Issue contains an enhancement related to a specific component. Additional functionality has been add

Comments

@davidbejarcaceres
Copy link

davidbejarcaceres commented Aug 3, 2021

I'm submitting a ...

[ x] bug report
[ ] feature request
[ ] support request => Please do not submit support request here, instead see https://forum.primefaces.org/viewforum.php?f=57

Codesandbox Case (Bug Reports)
https://codesandbox.io/s/exciting-villani-vqex4?file=/src/demo/CascadeSelectDemo.js:6294-6507

Current behavior
The issue with cascade select happens when the list is too long for the page to display in available space below the component, so it creates scrolls to the whole page instead of creating scroll just for the list container of the dropdown. When the list have many elements, and those elements have multiple levels.

image

Expected behavior
I found a custom fix to limit height of the cascade select container to prevent cascade to create scrolls in page and limits the max-height to the space in screen available below the component, the right CascadeSelect uses this strategy, but still, only the second container for the child items are limited and using the scroll as intended, the first level of items is limited to the space but the items are going below the limit without a scroll-y appearing.
We probably need a portal to fix this problem to use only available space in screen to display the dropdown preventing to create scrolls in the whole page, and just create scrolls in the items containers of the list in each level of children items.

image

Minimal reproduction of the problem with instructions

  1. Place a CascadeSelec in the page (preferably vertically centered or the the bottom of the screen).
  2. Add multiple "options" and each option with children, add enough of them so the dropdown list container goes below the screen space available.
  3. You can see scroll bars for page are created, instead of adding scroll bars to the container of the list for each level in the DropDown.

Please tell us about your environment:
Browser Chrome v92.0.4515.107, OS Windows 10 20h1
"react": "^16.10.2",
"primeflex": "^2.0.0",
"primeicons": "^4.1.0",
"primereact": "^6.4.1",

  • React version:
    16.10.2

  • PrimeReact version:
    6.4.1

  • Browser:

  • Chrome v92.0.4515.107
  • Firefox v90.0.2
  • Language:
    Javascript
@mertsincan mertsincan added the Type: Enhancement Issue contains an enhancement related to a specific component. Additional functionality has been add label Nov 8, 2021
@mertsincan mertsincan added this to the 8.0.0 milestone Nov 8, 2021
@mertsincan mertsincan modified the milestones: 8.2.0, Future Jul 6, 2022
@melloware
Copy link
Member

PrimeVue same issue: primefaces/primevue#3337

@melloware melloware changed the title CascadeSelect dropdown container creates scrolls in page instead of list container CascadeSelect: dropdown container creates scrolls in page instead of list container Dec 7, 2022
@kl-nevermore
Copy link
Contributor

kl-nevermore commented Dec 19, 2023

@melloware this may require adjusting the dom structure, I feel like there will be some breakchanges or css change,
I will try to fix it in our team tomorrow and test, then I can pr

I will also try using the portal

@melloware
Copy link
Member

Can you also check what PrimeVue and PrimeNG are doing?

@kl-nevermore
Copy link
Contributor

kl-nevermore commented Dec 20, 2023

@melloware
There is a mobile-related one in primeng, but primeng can support this feature because the sublist wrapped by p-cascadeselectsub and position set here
demo

image

image

in primevue and primereact the sublist has no parent box, if set overflow and absolute for ul, the child elements would be affected
image

20231220110205_rec_
demo-react

@kl-nevermore
Copy link
Contributor

kl-nevermore commented Dec 20, 2023

Do you think we should follow primeng's implementation?

This will move p-cascadeselect-sublist to parent element and change classes(it's a breakchange?)
but when we use pt, the sublist will be applied to ul, I think there might be some ambiguity

This is how I currently implement it e.g.

 const listWrapperProps = mergeProps(
    {
        className: cx('sublistWrapper')
    },
    getPTOptions('sublistWrapper')
);
return props.level === 0 ? <>{ul}</> : <div {...listWrapperProps}>{ul}</div>;

//css
.p-cascadeselect-sublist-wrapper {
        position: absolute;
        min-width: 100%;
        z-index: 1;
        display: none;
    }

@melloware
Copy link
Member

yep we can probabaly make it like PrimeNG especially if that solves the issue.

@kl-nevermore
Copy link
Contributor

kl-nevermore commented Dec 21, 2023

I found PrimeNG has not yet implemented PT and unstyled

To fix this problem need to add a new pt

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Enhancement Issue contains an enhancement related to a specific component. Additional functionality has been add
Projects
None yet
4 participants