mirror of
https://github.com/laurent22/joplin.git
synced 2025-01-11 18:24:43 +02:00
Mobile: Fixes #433: Don't scroll note back to top when changing checkbox state
This commit is contained in:
parent
f5bca733d7
commit
595cf3fcad
@ -39,6 +39,19 @@ class NoteBodyViewer extends Component {
|
||||
}, 100);
|
||||
}
|
||||
|
||||
shouldComponentUpdate(nextProps, nextState) {
|
||||
// To address https://github.com/laurent22/joplin/issues/433
|
||||
// If a checkbox in a note is ticked, the body changes, which normally would trigger a re-render
|
||||
// of this component, which has the unfortunate side effect of making the view scroll back to the top.
|
||||
// This re-rendering however is uncessary since the component is already visually updated via JS.
|
||||
// So here, if the note has not changed, we prevent the component from updating.
|
||||
// This fixes the above issue. A drawback of this is if the note is updated via sync, this change
|
||||
// will not be displayed immediately.
|
||||
const currentNoteId = this.props && this.props.note ? this.props.note.id : null;
|
||||
const nextNoteId = nextProps && nextProps.note ? nextProps.note.id : null;
|
||||
return currentNoteId !== nextNoteId || nextState.webViewLoaded !== this.state.webViewLoaded;
|
||||
}
|
||||
|
||||
render() {
|
||||
const note = this.props.note;
|
||||
const style = this.props.style;
|
||||
@ -109,7 +122,7 @@ class NoteBodyViewer extends Component {
|
||||
let msg = event.nativeEvent.data;
|
||||
|
||||
if (msg.indexOf('checkboxclick:') === 0) {
|
||||
const newBody = this.mdToHtml_.handleCheckboxClick(msg, note.body);
|
||||
const newBody = this.mdToHtml_.handleCheckboxClick(msg, this.props.note.body);
|
||||
if (onCheckboxChange) onCheckboxChange(newBody);
|
||||
} else if (msg.indexOf('bodyscroll:') === 0) {
|
||||
//msg = msg.split(':');
|
||||
|
@ -512,7 +512,13 @@ class NoteScreenComponent extends BaseScreenComponent {
|
||||
this.saveOneProperty('body', newBody);
|
||||
};
|
||||
|
||||
bodyComponent = <NoteBodyViewer onJoplinLinkClick={this.onJoplinLinkClick_} style={this.styles().noteBodyViewer} webViewStyle={theme} note={note} onCheckboxChange={(newBody) => { onCheckboxChange(newBody) }}/>
|
||||
bodyComponent = <NoteBodyViewer
|
||||
onJoplinLinkClick={this.onJoplinLinkClick_}
|
||||
style={this.styles().noteBodyViewer}
|
||||
webViewStyle={theme}
|
||||
note={note}
|
||||
onCheckboxChange={(newBody) => { onCheckboxChange(newBody) }}
|
||||
/>
|
||||
} else {
|
||||
const focusBody = !isNew && !!note.title;
|
||||
|
||||
|
@ -143,24 +143,11 @@ async function translationStatus(isDefault, poFile) {
|
||||
translatorName = extractTranslator(/Language-Team:\s*?(.*)/, content);
|
||||
}
|
||||
|
||||
// Remove <> around email otherwise it's converted to HTML with (apparently) non-deterministic
|
||||
// encoding, so it changes on every update.
|
||||
translatorName = translatorName.replace(/ </, ' (');
|
||||
translatorName = translatorName.replace(/>/, ')');
|
||||
|
||||
// "Last-Translator: Hrvoje Mandić <trbuhom@net.hr>\n"
|
||||
// let translatorMatch = content.match(/Last-Translator:\s*?(.*)/);
|
||||
// if (translatorMatch.length < 1) {
|
||||
// translatorMatch = content.match(/Last-Team:\s*?(.*)/);
|
||||
// }
|
||||
|
||||
// if (translatorMatch.length >= 1) {
|
||||
// translatorName = translatorMatch[1];
|
||||
// translatorName = translatorName.replace(/["\s]+$/, '');
|
||||
// translatorName = translatorName.replace(/\\n$/, '');
|
||||
// translatorName = translatorName.replace(/^\s*/, '');
|
||||
// }
|
||||
|
||||
// if (translatorName.indexOf('FULL NAME') >= 0) translatorName = '';
|
||||
|
||||
return {
|
||||
percentDone: isDefault ? 100 : percentDone,
|
||||
translatorName: translatorName,
|
||||
|
Loading…
Reference in New Issue
Block a user