Skip to content

Commit

Permalink
fix: discussion list pane broken if has no items
Browse files Browse the repository at this point in the history
  • Loading branch information
YUCLing committed Nov 14, 2024
1 parent 40acd7b commit e29df8a
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions framework/core/js/src/forum/components/DiscussionListPane.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,10 @@ export default class DiscussionListPane extends Component {
oncreate(vnode) {
super.oncreate(vnode);

document.addEventListener('mousemove', hotEdge);

const list = vnode.dom;
if (!list) return;

// When the mouse enters and leaves the discussions pane, we want to show
// and hide the pane respectively. We also create a 10px 'hot edge' on the
Expand All @@ -37,8 +40,6 @@ export default class DiscussionListPane extends Component {
list.addEventListener('mouseenter', pane.show.bind(pane));
list.addEventListener('mouseleave', pane.onmouseleave.bind(pane));

document.addEventListener('mousemove', hotEdge);

// When coming from another discussion, scroll to the previous position
// to prevent the discussion list jumping around.
if (app.previous.matches(DiscussionPage)) {
Expand Down Expand Up @@ -66,7 +67,8 @@ export default class DiscussionListPane extends Component {
}

onremove(vnode) {
app.cache.discussionListPaneScrollTop = vnode.dom.scrollTop;
if (vnode.dom)
app.cache.discussionListPaneScrollTop = vnode.dom.scrollTop;
document.removeEventListener('mousemove', hotEdge);
}

Expand Down

0 comments on commit e29df8a

Please sign in to comment.