I am sharing the example code which is showing a search bar and scrollbar for a div, but searched text should navigate to matched place and scrollbar also should move to bottom when the text is in last line or middle or inside any place.
You can solve it (I implemented at least the scollTop-position) the following way:
ngAfterContentChecked(): void {
if (this.$backdrop) {
this.handleScroll();
}
}
handleScroll() {
const markElem = this.$backdrop.nativeElement.querySelector('mark');
if (markElem) {
this.$backdrop.nativeElement.scrollTop = markElem.offsetTop;
this.$textarea.nativeElement.scrollTop = markElem.offsetTop;
}
}
Check this StackBlitz with the changes to your code: