Skip to content

Commit

Permalink
Fix conversation search and list to morph on refresh (#581)
Browse files Browse the repository at this point in the history
Co-authored-by: Keith Schacht <krschacht@gmail.com>
  • Loading branch information
mattlindsey and krschacht authored Dec 27, 2024
1 parent 64004c4 commit f4828c2
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
4 changes: 4 additions & 0 deletions app/javascript/stimulus/search_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ export default class extends Controller {

inputTargetConnected() {
this.setSearchClearIcon()
// Ensure the cursor is at the end of the input
this.inputTarget.selectionStart =
this.inputTarget.selectionEnd =
this.inputTarget.value.length
}

disconnect() {
Expand Down
7 changes: 4 additions & 3 deletions app/views/conversations/index.html.erb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<turbo-frame data-turbo-permanent id="nav-conversations">
<turbo-frame id="nav-conversations">
<section id="search"
class="pt-6 text-gray-950 dark:text-gray-100 select-none"
>
Expand All @@ -17,11 +17,12 @@
w-full
p-2 py-1
border border-gray-200 rounded-lg
text-black dark:text-gray-800
text-black dark:text-gray-200
placeholder-gray-300 dark:placeholder-gray-500
bg-transparent
|,
data: {
search_target: "input",
turbo_permanent: true,
action: %|
blur->search#unfocus
input->search#search
Expand Down
1 change: 1 addition & 0 deletions app/views/messages/_nav_column.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,6 @@

<turbo-frame id="nav-conversations"
src="<%= conversations_path(conversation_id: @conversation&.id) %>"
refresh="morph"
loading="lazy"
/>

0 comments on commit f4828c2

Please sign in to comment.