Skip to content

Commit e7270d6

Browse files
authored
Keep scroll at the bottom when new output is appended (#149)
This works by using flex-direction: column-reverse so the browser will treat the div as being reverted and will keep the scroll at the bottom instead of top. The extra div is necessary so the content doesn't have to be written inverted
1 parent 3ef8a30 commit e7270d6

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

lib/elixir_console_web/live/console_live.html.heex

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
<div class="flex h-full flex-col sm:flex-row">
2-
<div class="flex-1 sm:h-full overflow-scroll">
2+
<div class="flex-1 sm:h-full">
33
<div class="h-full flex flex-col">
44
<div class="flex-1"></div>
5-
<%= live_component(HistoryComponent, output: @output, id: :history) %>
6-
<%= live_component(CommandInputComponent, history: @history, bindings: @sandbox.bindings, id: :command_input) %>
5+
<div class="flex flex-col-reverse overflow-auto">
6+
<div>
7+
<%= live_component(HistoryComponent, output: @output, id: :history) %>
8+
<%= live_component(CommandInputComponent, history: @history, bindings: @sandbox.bindings, id: :command_input) %>
9+
</div>
10+
</div>
711
</div>
812
</div>
913
<%= live_component(SidebarComponent,

0 commit comments

Comments
 (0)