Skip to content

Commit

Permalink
Fix primefaces#1879: Input focus() should not scroll unless autoFocus…
Browse files Browse the repository at this point in the history
…=true
  • Loading branch information
melloware committed May 6, 2022
1 parent 649e958 commit f5c7952
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions components/lib/utils/DomHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -789,14 +789,14 @@ export default class DomHandler {
}

/**
* Focus an input element.
* Focus an input element if it does not already have focus.
*
* @param {MutableRefObject} inputRef the input reference
* @param {boolean} scrollTo flag to control whether to scroll to the element, false by default
*/
static focus(inputRef, scrollTo) {
const preventScroll = ObjectUtils.isEmpty(scrollTo) ? true : !scrollTo;
inputRef && inputRef.current && inputRef.current.focus({ preventScroll: preventScroll });
inputRef && inputRef.current && document.activeElement !== inputRef.current && inputRef.current.focus({ preventScroll: preventScroll });
}

static getCursorOffset(el, prevText, nextText, currentText) {
Expand Down

0 comments on commit f5c7952

Please sign in to comment.