Skip to content

Commit

Permalink
#5675 PickList scroll fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
yigitfindikli committed Jan 10, 2024
1 parent 1fc1da3 commit 1a05a21
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions components/lib/picklist/PickList.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,24 +63,22 @@ export const PickList = React.memo(

const handleScrollPosition = (listElement, direction) => {
if (listElement) {
let list = DomHandler.findSingle(listElement, '[data-pc-section="list"]');

switch (direction) {
case 'up':
scrollInView(list, -1);
scrollInView(listElement, -1);
break;

case 'top':
list.scrollTop = 0;
listElement.scrollTop = 0;
break;

case 'down':
scrollInView(list, 1);
scrollInView(listElement, 1);
break;

case 'bottom':
/* TODO: improve this code block */
setTimeout(() => (list.scrollTop = list.scrollHeight), 100);
setTimeout(() => (listElement.scrollTop = listElement.scrollHeight), 100);
break;

default:
Expand Down Expand Up @@ -602,7 +600,7 @@ export const PickList = React.memo(
onListBlur={(e) => onListBlur(e, 'source')}
onOptionMouseDown={(index) => onOptionMouseDown(index, 'source')}
onItemClick={(e) => onItemClick(e, 'source')}
focusedOptionId={focusedOptionId}
focusedOptionId={focused['source'] ? focusedOptionId : null}
ariaActivedescendant={focused['source'] ? focusedOptionId : null}
itemTemplate={sourceItemTemplate}
header={props.sourceHeader}
Expand Down Expand Up @@ -656,7 +654,7 @@ export const PickList = React.memo(
onListBlur={(e) => onListBlur(e, 'target')}
onOptionMouseDown={(index) => onOptionMouseDown(index, 'target')}
onItemClick={(e) => onItemClick(e, 'target')}
focusedOptionId={focusedOptionId}
focusedOptionId={focused['target'] ? focusedOptionId : null}
ariaActivedescendant={focused['target'] ? focusedOptionId : null}
itemTemplate={targetItemTemplate}
header={props.targetHeader}
Expand Down

0 comments on commit 1a05a21

Please sign in to comment.