Skip to content

Commit

Permalink
fix(SearchDialog): Scroll search element in reader/editor into view
Browse files Browse the repository at this point in the history
Signed-off-by: Jonas <jonas@freesources.org>
  • Loading branch information
mejo- authored and elzody committed Aug 13, 2024
1 parent 105ccab commit 29b7850
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/components/SearchDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
import { NcButton, NcCheckboxRadioSwitch } from '@nextcloud/vue'
import { translate as t } from '@nextcloud/l10n'
import { mapActions, mapState } from 'pinia'
import { useRootStore } from '../stores/root.js'
import { useSearchStore } from '../stores/search.js'
import ArrowDown from 'vue-material-design-icons/ArrowDown.vue'
import ArrowUp from 'vue-material-design-icons/ArrowUp.vue'
Expand Down Expand Up @@ -92,6 +93,7 @@ export default {
},

computed: {
...mapState(useRootStore, ['isTextEdit']),
...mapState(useSearchStore, [
'searchQuery',
'matchAll',
Expand Down Expand Up @@ -135,8 +137,15 @@ export default {
this.showSearchDialog(false)
},

getActiveTextElement() {
return this.isTextEdit
? document.querySelector('[data-collectives-el="editor"]')
: document.querySelector('[data-collectives-el="reader"]')
},

scrollIntoView() {
document.querySelector('[data-text-el="search-decoration"]')?.scrollIntoView({ block: 'center' })
this.getActiveTextElement()
.querySelector('[data-text-el="search-decoration"]')?.scrollIntoView({ block: 'center' })
},
},
}
Expand Down

0 comments on commit 29b7850

Please sign in to comment.