Chat Scrolling using pageup/pagedown keys is broken (solution provided)

Continuing the discussion from Scroll in chat:

As I’ve posted in the topic above, the default way the chat resource tries to use the pageup and pagedown keys for scrolling in chat does not work. I’ve made some small changes to make it work, those changes can be found in the topic above. I’ve also included them in the bug report format below.


Bug Report Format

Describe a detailed explanation of the bug you were experiencing
When the chat is open, pressing pageup or pagedown to scroll up or down in the chat does not work. I’ve looked at the code in the Chat resource that should make this work. I’ve found a bug with the way the ‘chat-messages’ div is being obtained. According to this reference, using $refs in a render() method is not supported. That means that the approach from the chat resource won’t work.


To fix this I’ve changed these lines in /resources/[system]/chat/html/App.js:
Lines 108 and 111 from this:

const buf = $(this.$refs.messages);

To this:

var buf = document.getElementsByClassName('chat-messages')[0];

Also the lines 109 and 112 don’t seem to work:

buf.scrollTop(buf.scrollTop() - 50);    -- line 109
buf.scrollTop(buf.scrollTop() + 50);    -- line 112

So I’ve changed those to the following:

buf.scrollTop = buf.scrollTop - 100;    -- line 109
buf.scrollTop = buf.scrollTop + 100;    -- line 112

Add screenshots if possible
N/A (info above speaks for itself)

Add a date and time to when it happend (only neccesary when it’s not happening constantly).
N/A

Thanks! Can you provide a pull request to https://github.com/citizenfx/cfx-server-data to reduce the chance of us breaking this when manually applying?

1 Like

I’ll take a look but I’m very new to github, just fyi.
Update: just made a pull request (I think/hope :wink: )