Focus buffer scrollview instead of composer

Instead of focusing the composer, focus the buffer scrollview when
switching to a buffer. This allows keyboard navigation to work as
expected, with arrow up/down and page up/down scrolling the buffer
instead of doing nothing.

Focus back the composer when a KeyboardEvent produces text. This
allows users to start typing a message right after switching to a
buffer.

Closes: https://todo.sr.ht/~emersion/gamja/64
This commit is contained in:
Simon Ser 2021-06-22 14:44:20 +02:00
parent dc8f95c74d
commit 724d7318cf
2 changed files with 31 additions and 8 deletions

View file

@ -290,8 +290,8 @@ export default class App extends Component {
lastReadReceipt,
});
if (this.composer.current) {
this.composer.current.focus();
if (this.buffer.current) {
this.buffer.current.focus();
}
if (buf.messages.length == 0) {
@ -1275,7 +1275,7 @@ export default class App extends Component {
scrollKey=${this.state.activeBuffer}
onScrollTop=${this.handleBufferScrollTop}
>
<section id="buffer" ref=${this.buffer}>
<section id="buffer" ref=${this.buffer} tabindex="-1">
<${Buffer}
buffer=${activeBuffer}
server=${activeServer}