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

Prevent multiselect/dropdown box from closing on page scroll #5872

Closed
kslb30 opened this issue Feb 1, 2024 · 4 comments · Fixed by #5873
Closed

Prevent multiselect/dropdown box from closing on page scroll #5872

kslb30 opened this issue Feb 1, 2024 · 4 comments · Fixed by #5873
Assignees
Labels
Component: Documentation Issue or pull request is related to Documentation Resolution: By Design The behavior in the issue is by design and the component exhibits the expected behavior
Milestone

Comments

@kslb30
Copy link

kslb30 commented Feb 1, 2024

Describe the bug

When using the multiselect or dropdown component, when you open the select box and scroll vertically on the page, the select box closes automatically, and there's no way to keep it open.
The most frustrating part is that in the documentation, the select box remain open even if you scroll on the page, but in practice, it's impossible to keep them open...

Reproducer

https://c3tk48.sse.codesandbox.io/

PrimeReact version

10.3.1

React version

18.x

Language

TypeScript

Build / Runtime

Create React App (CRA)

Browser(s)

No response

Steps to reproduce the behavior

  1. Go https://c3tk48.sse.codesandbox.io/
  2. Open the select box
  3. Reduce the window and display the console to have a vertical scroll
  4. Scroll on the page will close automatically the select box

Expected behavior

Do not close automatically the select box when scrolling on the page or add an option to manage it (Dropdown and MultiSelect components)

@kslb30 kslb30 added the Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible label Feb 1, 2024
@melloware
Copy link
Member

It works fine try mine: https://stackblitz.com/edit/rhacf7?file=src%2FApp.tsx,src%2Findex.css

Key is your body CSS has to overflow:

body {
  margin: 0px;
  min-height: 100%;
  overflow-x: hidden;
  overflow-y: auto;
  background-color: var(--surface-ground);
  font-weight: normal;
  color: var(--text-color);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

@melloware melloware closed this as not planned Won't fix, can't repro, duplicate, stale Feb 1, 2024
@melloware melloware added Resolution: By Design The behavior in the issue is by design and the component exhibits the expected behavior and removed Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible labels Feb 1, 2024
melloware added a commit to melloware/primereact that referenced this issue Feb 1, 2024
@melloware melloware self-assigned this Feb 1, 2024
@melloware melloware added this to the 10.4.1 milestone Feb 1, 2024
@melloware melloware added the Component: Documentation Issue or pull request is related to Documentation label Feb 1, 2024
@ScrKiddie
Copy link

It works fine try mine: https://stackblitz.com/edit/rhacf7?file=src%2FApp.tsx,src%2Findex.css

Key is your body CSS has to overflow:

body {
  margin: 0px;
  min-height: 100%;
  overflow-x: hidden;
  overflow-y: auto;
  background-color: var(--surface-ground);
  font-weight: normal;
  color: var(--text-color);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

It's working perfectly when the dropdown is outside the dialog. How can I fix the dropdown inside the dialog without setting the dialog height to 100%?

@melloware
Copy link
Member

Inside the dialog you need to use the appendTo property: https://primereact.org/dropdown/#api.Dropdown.props.appendTo

@antman888
Copy link

Inside the dialog you need to use the appendTo property: https://primereact.org/dropdown/#api.Dropdown.props.appendTo

What should it be appended to? Here's an example in a dialog with a TreeSelect that closes the menu on scroll:
https://stackblitz.com/edit/rhacf7-qrr9xf?file=src%2FApp.tsx

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: Documentation Issue or pull request is related to Documentation Resolution: By Design The behavior in the issue is by design and the component exhibits the expected behavior
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants