Edv Beq
Edv Beq

Reputation: 1000

Scrollbar disappears under list

As the title says, I tried to wrap a <ListGroup> with <Scrollbars> but when I hover the mouse over it the scrollbar disappears under one of the items. I don't have any css applied to it. This is a React app. Any ideas how to fix this?

react-custom-scrollbars

reactstrap

Here is the sample code from the top div

import React from 'react';
import { Card, ListGroup, ListGroupItem, Badge, ListGroupItemText } from 'reactstrap';
import { Scrollbars } from 'react-custom-scrollbars';

  <div className="shadow-sm">
    <Card>
      <Scrollbars style={{ width: 350, height: 250 }} >
        <ListGroup>
          <ListGroupItem className="justify-content-between">Cras justo odio <Badge pill>14</Badge>
            <ListGroupItemText>
              Donec id elit non mi porta gravida at eget metus. Maecenas sed diam eget risus varius blandit.
            </ListGroupItemText>
          </ListGroupItem>
          <ListGroupItem className="justify-content-between">Dapibus ac facilisis in <Badge pill>2</Badge></ListGroupItem>
          <ListGroupItem className="justify-content-between">Morbi leo risus <Badge pill>1</Badge></ListGroupItem>
          <ListGroupItem className="justify-content-between">Dapibus ac facilisis in <Badge pill>2</Badge></ListGroupItem>
          <ListGroupItem className="justify-content-between">Morbi leo risus <Badge pill>1</Badge></ListGroupItem>
          <ListGroupItem className="justify-content-between">Morbi leo risus <Badge pill>1</Badge></ListGroupItem>
        </ListGroup>
      </Scrollbars>
    </Card>
  </div>

Here is an image to further clarify enter image description here

Here is the css that I was able to find for the two components

// scroll-bar
element.style {
    position: relative;
    display: block;
    width: 100%;
    cursor: pointer;
    border-radius: inherit;
    background-color: rgba(0, 0, 0, 0.2);
    height: 161px;
    transform: translateY(26.5865px);

// list-item
.list-group-item {
    position: relative;
    display: block;
    padding: 0.75rem 1.25rem;
    margin-bottom: -1px;
    background-color: #fff;
    border: 1px solid rgba(0, 0, 0, 0.125);
} 

I can add a margin but I don't like how it looks. I would rather have the scrollbar on top of the list - since I can also choose to hide it when not scrolling. Thanks

Upvotes: 1

Views: 450

Answers (1)

Julia
Julia

Reputation: 704

I've fixed it adding a custom style as described here https://github.com/malte-wessel/react-custom-scrollbars/blob/master/docs/customization.md

// in css
  .thumb-vertical {
    background-color: rgba(0, 0, 0, 0.6);
    border-radius: 3px;
    z-index: 2;
    cursor: pointer;
  }

// in component
<Scrollbars
  renderThumbVertical={props => <div {...props} className="thumb-vertical"/>}
> ...
</Scrollbars>

Upvotes: 1

Related Questions