mirror of
https://github.com/laurent22/joplin.git
synced 2024-12-30 10:36:35 +02:00
Desktop: Fixes #1833: Do not scroll text when search is open and user type in note
This commit is contained in:
parent
5a9b3b6c7c
commit
09df315639
@ -270,6 +270,7 @@ class NoteTextComponent extends React.Component {
|
||||
localSearch: {
|
||||
query: query,
|
||||
selectedIndex: 0,
|
||||
timestamp: Date.now(),
|
||||
},
|
||||
});
|
||||
};
|
||||
@ -277,6 +278,7 @@ class NoteTextComponent extends React.Component {
|
||||
const noteSearchBarNextPrevious = inc => {
|
||||
const ls = Object.assign({}, this.state.localSearch);
|
||||
ls.selectedIndex += inc;
|
||||
ls.timestamp = Date.now();
|
||||
if (ls.selectedIndex < 0) ls.selectedIndex = ls.resultCount - 1;
|
||||
if (ls.selectedIndex >= ls.resultCount) ls.selectedIndex = 0;
|
||||
|
||||
@ -1934,6 +1936,7 @@ class NoteTextComponent extends React.Component {
|
||||
];
|
||||
markerOptions.selectedIndex = this.state.localSearch.selectedIndex;
|
||||
markerOptions.separateWordSearch = false;
|
||||
markerOptions.searchTimestamp = this.state.localSearch.timestamp;
|
||||
} else {
|
||||
const search = BaseModel.byId(this.props.searches, this.props.selectedSearchId);
|
||||
if (search) {
|
||||
|
@ -227,7 +227,11 @@
|
||||
|
||||
ipcProxySendToHost('setMarkerCount', elementIndex);
|
||||
|
||||
if (selectedElement) selectedElement.scrollIntoView();
|
||||
// We only scroll the element into view if the search just happened. So when the user type the search
|
||||
// or select the next/previous result, we scroll into view. However for other actions that trigger a
|
||||
// re-render, we don't scroll as this is normally not wanted.
|
||||
// This is to go around this issue: https://github.com/laurent22/joplin/issues/1833
|
||||
if (selectedElement && Date.now() - options.searchTimestamp <= 1000) selectedElement.scrollIntoView();
|
||||
}
|
||||
|
||||
let markLoaded_ = false;
|
||||
|
Loading…
Reference in New Issue
Block a user