fix(feedback): Scroll to the top when opening feedback dialog

This commit is contained in:
Vlad Piersec
2021-09-15 11:13:05 +03:00
committed by vp8x8
parent 07da5940a5
commit 380ef3da0b
2 changed files with 27 additions and 11 deletions

View File

@@ -36,6 +36,10 @@ const SCORES = [
'feedback.veryGood'
];
type Scrollable = {
scroll: Function
}
/**
* The type of the React {@code Component} props of {@link FeedbackDialog}.
*/
@@ -171,6 +175,12 @@ class FeedbackDialog extends Component<Props, State> {
this._onScoreContainerMouseLeave
= this._onScoreContainerMouseLeave.bind(this);
this._onSubmit = this._onSubmit.bind(this);
// On some mobile browsers opening Feedback dialog scrolls down the whole content because of the keyboard.
// By scrolling to the top we prevent hiding the feedback stars so the user knows those exist.
this._onScrollTop = (node: ?Scrollable) => {
node && node.scroll && node.scroll(0, 0);
};
}
/**
@@ -244,6 +254,7 @@ class FeedbackDialog extends Component<Props, State> {
<Dialog
okKey = 'dialog.Submit'
onCancel = { this._onCancel }
onDialogRef = { this._onScrollTop }
onSubmit = { this._onSubmit }
titleKey = 'feedback.rateExperience'>
<div className = 'feedback-dialog'>
@@ -364,6 +375,8 @@ class FeedbackDialog extends Component<Props, State> {
return true;
}
_onScrollTop: (node: ?Scrollable) => void;
}
/**