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

Scroll Panel Bars not displaying correctly when the scrollpanel loses/gains width #9727

Closed
LarsHabier opened this issue Jan 7, 2021 · 1 comment
Assignees
Labels
Type: Bug Issue contains a bug related to a specific component. Something about the component is not working
Milestone

Comments

@LarsHabier
Copy link

LarsHabier commented Jan 7, 2021

I'm submitting a ... (check one with "x")

[X] bug report => Search github for a similar issue or PR before submitting
[ ] feature request => Please check if request is not on the roadmap already https://github.com/primefaces/primeng/wiki/Roadmap
[ ] support request => Please do not submit support request here, instead see http://forum.primefaces.org/viewforum.php?f=35

Current behavior
If you are using the primeng scrollpanel in a horizontal layout (e.g. a div on the left and the scroll panel on the right side) and change the width of the div, the scroll panel bars are not displayed correctly. They appear to use the "old" positions although they should be calculated new when the overall width of the scrollpanel changes.

Expected behavior
The scrollpanel should calculate the correct positions of the scrollpanel bars if the width of the scrollpanel itself changes.

Minimal reproduction of the problem with instructions

  1. Visit DEMO
  2. Move your cursor to the button saying "Click me to change the width of the rectangle". Make sure you do not move the cursor outside of the scrollpanel.
  3. Click the button which leads to the red div to receive a smaller width.
  4. The scrollpanel bars are moving too although they should not.
  5. If you move your cursor outside the scrollpanel and back in, the scrollbars get displayed correctly again.

What is the motivation / use case for changing the behavior?

We want to use a Sidebar on the left side of our application. The sidebar can be expanded so the given menu entries get a label. Obviously the sidebar gains width and the corresponding "main content" on the right loses width. The whole "main content" is wrapped in a scrollpanel.

Please tell us about your environment:

  • Angular version: 11.0.5
  • PrimeNG version: 11.0.0
  • Browser: [all | Chrome XX | Firefox XX | IE XX | Safari XX | Mobile Chrome XX | Android X.X Web Browser | iOS XX Safari | iOS XX UIWebView | iOS XX WKWebView ]
  • Language: [all | TypeScript X.X | ES6/7 | ES5]

  • Node (for AoT issues): node --version =

@LarsHabier LarsHabier changed the title Scroll Panel Bars not displaying correctly when the window size gets changed Scroll Panel Bars not displaying correctly when the scrollpanel loses/gains width Jan 7, 2021
@yigitfindikli yigitfindikli added the Status: Pending Review Issue or pull request is being reviewed by Core Team label Jan 8, 2021
@is-tongben
Copy link
Contributor

@LarsHabier @yigitfindikli
Look at the source code to find the reason,I also encountered this problem, has been solved,I could write it this way

- html
   <p-scrollPanel #scrollPanelChild [style]="scrollPanelStyle">
       ...content
   </p-scrollPanel>
- ts
   public scrollPanelStyle = {width: '180px', height: '0px'};
   @ViewChild('scrollPanelChild', { static: false })
   public scrollPanelChild: ScrollPanel;

  ... 
    this.scrollPanelStyle.width = "xxxpx";
    this.scrollPanelChild?.cd.markForCheck();
  

@yigitfindikli yigitfindikli added Type: Bug Issue contains a bug related to a specific component. Something about the component is not working and removed Status: Pending Review Issue or pull request is being reviewed by Core Team labels Mar 26, 2021
@yigitfindikli yigitfindikli self-assigned this Mar 26, 2021
@yigitfindikli yigitfindikli added this to the 11.3.2 milestone Mar 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Bug Issue contains a bug related to a specific component. Something about the component is not working
Projects
None yet
Development

No branches or pull requests

3 participants