Skip to content

Commit

Permalink
Fixed #2142 - When clicking on the target element to open the confirm…
Browse files Browse the repository at this point in the history
…Popup, the browser's scroll moves
  • Loading branch information
mertsincan committed Jun 25, 2021
1 parent 2986de1 commit f7be3a3
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/components/confirmpopup/ConfirmPopup.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ export class ConfirmPopup extends Component {
this.onExited = this.onExited.bind(this);

this.overlayRef = React.createRef();
this.acceptBtnRef = React.createRef();
}

acceptLabel() {
Expand Down Expand Up @@ -243,6 +244,10 @@ export class ConfirmPopup extends Component {
this.bindScrollListener();
this.bindResizeListener();

if (this.acceptBtnRef && this.acceptBtnRef.current) {
this.acceptBtnRef.current.focus();
}

this.props.onShow && this.props.onShow();
}

Expand Down Expand Up @@ -324,7 +329,7 @@ export class ConfirmPopup extends Component {
const content = (
<div className="p-confirm-popup-footer">
<Button label={this.rejectLabel()} icon={this.props.rejectIcon} className={rejectClassName} onClick={this.reject} />
<Button label={this.acceptLabel()} icon={this.props.acceptIcon} className={acceptClassName} onClick={this.accept} autoFocus />
<Button ref={this.acceptBtnRef} label={this.acceptLabel()} icon={this.props.acceptIcon} className={acceptClassName} onClick={this.accept} />
</div>
)

Expand Down

0 comments on commit f7be3a3

Please sign in to comment.