Skip to content

Commit

Permalink
Horizontal update
Browse files Browse the repository at this point in the history
added stopPropagation to horizontal
  • Loading branch information
David Yushkov committed Aug 29, 2021
1 parent e23c54f commit 542cadb
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ const HorizontalScrollbar = () => {
const props = Movable.useMove(useMemo(() => [move(container, thumb, track)], [container]));

const handleOnClick = e => {
e.stopPropagation();
// Ignore clicks on the thumb itself
if (!thumb.current.contains(e.target)) {
const {left, width} = track.current.getBoundingClientRect();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ describe('<HorizontalScrollbar/>', () => {
rewire.__Rewire__('useContext', () => ({container}));
const wrapper = shallow(<HorizontalScrollbar/>);

wrapper.find('.scrollbar-track').prop('onClick')({clientX: 0});
wrapper.find('.scrollbar-track').prop('onClick')({clientX: 0, stopPropagation: noop});
expect(container.current.scrollLeft).toEqual(0);

wrapper.find('.scrollbar-track').prop('onClick')({clientX: 50});
wrapper.find('.scrollbar-track').prop('onClick')({clientX: 50, stopPropagation: noop});
expect(container.current.scrollLeft).toEqual(100);

rewire.__ResetDependency__('useRef');
Expand Down

0 comments on commit 542cadb

Please sign in to comment.