mirror of
https://github.com/laurent22/joplin.git
synced 2025-01-05 12:50:29 +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: {
|
localSearch: {
|
||||||
query: query,
|
query: query,
|
||||||
selectedIndex: 0,
|
selectedIndex: 0,
|
||||||
|
timestamp: Date.now(),
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
@ -277,6 +278,7 @@ class NoteTextComponent extends React.Component {
|
|||||||
const noteSearchBarNextPrevious = inc => {
|
const noteSearchBarNextPrevious = inc => {
|
||||||
const ls = Object.assign({}, this.state.localSearch);
|
const ls = Object.assign({}, this.state.localSearch);
|
||||||
ls.selectedIndex += inc;
|
ls.selectedIndex += inc;
|
||||||
|
ls.timestamp = Date.now();
|
||||||
if (ls.selectedIndex < 0) ls.selectedIndex = ls.resultCount - 1;
|
if (ls.selectedIndex < 0) ls.selectedIndex = ls.resultCount - 1;
|
||||||
if (ls.selectedIndex >= ls.resultCount) ls.selectedIndex = 0;
|
if (ls.selectedIndex >= ls.resultCount) ls.selectedIndex = 0;
|
||||||
|
|
||||||
@ -1934,6 +1936,7 @@ class NoteTextComponent extends React.Component {
|
|||||||
];
|
];
|
||||||
markerOptions.selectedIndex = this.state.localSearch.selectedIndex;
|
markerOptions.selectedIndex = this.state.localSearch.selectedIndex;
|
||||||
markerOptions.separateWordSearch = false;
|
markerOptions.separateWordSearch = false;
|
||||||
|
markerOptions.searchTimestamp = this.state.localSearch.timestamp;
|
||||||
} else {
|
} else {
|
||||||
const search = BaseModel.byId(this.props.searches, this.props.selectedSearchId);
|
const search = BaseModel.byId(this.props.searches, this.props.selectedSearchId);
|
||||||
if (search) {
|
if (search) {
|
||||||
|
@ -227,7 +227,11 @@
|
|||||||
|
|
||||||
ipcProxySendToHost('setMarkerCount', elementIndex);
|
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;
|
let markLoaded_ = false;
|
||||||
|
Loading…
Reference in New Issue
Block a user