Skip to content
This repository has been archived by the owner on Sep 18, 2024. It is now read-only.

Commit

Permalink
fix: docbot overflow and scrolling (#216)
Browse files Browse the repository at this point in the history
  • Loading branch information
nomagick authored Nov 21, 2021
1 parent 7778855 commit 89511dc
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 9 deletions.
2 changes: 1 addition & 1 deletion docs/_static/docbot.css
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@
}

.ready .hidden-before-ready{
display: unset;
display: revert;
}

@media (prefers-color-scheme: dark) {
Expand Down
24 changes: 16 additions & 8 deletions docs/_static/docbot.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ $(document).ready(function () {
},
methods: {
notify_slack: function (question, answer, thumbup) {
const self = this;
$.ajax({
type: "POST",
url: app.slack_address,
Expand All @@ -45,10 +46,7 @@ $(document).ready(function () {
success: function (data, textStatus, jqXHR) {
// reset current question to empty
if (thumbup !== null) {
Array.from(document.getElementsByClassName("answer-bubble")).slice(-1)[0].scrollIntoView({
block: "nearest",
inline: "nearest"
});
self.scrollToBottom();
}
},
error: function (request, status, error) {
Expand All @@ -67,6 +65,11 @@ $(document).ready(function () {
app.notify_slack(qa.question, qa.answer, val);
},
submit_q: function () {
if (app.is_busy) {
return;
}
const self = this;
this.scrollToBottom();
app.is_busy = true;
app.is_conn_broken = false;
app.qa_pairs.push({ "question": app.cur_question, "rating": null });
Expand All @@ -91,13 +94,18 @@ $(document).ready(function () {
},
complete: function () {
app.is_busy = false;
Array.from(document.getElementsByClassName("answer-bubble")).slice(-1)[0].scrollIntoView({
block: "nearest",
inline: "nearest"
});
self.scrollToBottom();
}
});
},
scrollToBottom() {
setTimeout(() => {
Array.from(document.getElementsByClassName("qa-container")).pop().scrollIntoView({
block: "end",
inline: "nearest"
});
}, 100);
},
}
});
});

0 comments on commit 89511dc

Please sign in to comment.