fix: clicking on search result closes

This commit is contained in:
Zach Daniel 2022-09-19 17:14:15 -04:00
parent fa07573511
commit 3931ce262b
6 changed files with 46 additions and 20 deletions

27
.vscode/settings.json vendored
View file

@ -1,9 +1,4 @@
{
"workbench.colorCustomizations": {
"activityBar.background": "#541337",
"titleBar.activeBackground": "#761B4E",
"titleBar.activeForeground": "#FEFCFD"
},
"cSpell.words": [
"Callout",
"citext",
@ -20,5 +15,25 @@
"tsquery",
"tsvector",
"Tsvector"
]
],
"workbench.colorCustomizations": {
"activityBar.activeBackground": "#1f6fd0",
"activityBar.background": "#1f6fd0",
"activityBar.foreground": "#e7e7e7",
"activityBar.inactiveForeground": "#e7e7e799",
"activityBarBadge.background": "#ee90bb",
"activityBarBadge.foreground": "#15202b",
"commandCenter.border": "#e7e7e799",
"sash.hoverBorder": "#1f6fd0",
"statusBar.background": "#1857a4",
"statusBar.foreground": "#e7e7e7",
"statusBarItem.hoverBackground": "#1f6fd0",
"statusBarItem.remoteBackground": "#1857a4",
"statusBarItem.remoteForeground": "#e7e7e7",
"titleBar.activeBackground": "#1857a4",
"titleBar.activeForeground": "#e7e7e7",
"titleBar.inactiveBackground": "#1857a499",
"titleBar.inactiveForeground": "#e7e7e799"
},
"peacock.color": "#1857a4"
}

View file

@ -6,7 +6,7 @@ defmodule AshHqWeb.Components.Search do
alias AshHqWeb.Components.CalloutText
alias AshHqWeb.DocRoutes
alias Surface.Components.{Form, LivePatch}
alias Surface.Components.Form
alias Surface.Components.Form.{Checkbox, Label}
prop open, :boolean, default: false
@ -100,7 +100,13 @@ defmodule AshHqWeb.Components.Search do
defp render_items(assigns, items) do
~F"""
{#for item <- items}
<LivePatch to={DocRoutes.doc_link(item, @selected_versions)} opts={id: item.id}>
<button
class="block w-full text-left"
:on-click="go-to-doc"
phx-value-link={DocRoutes.doc_link(item, @selected_versions)}
phx-target={@myself}
id={item.id}
>
<div class={
"rounded-lg mb-4 py-2 px-2 hover:bg-base-dark-300 dark:hover:bg-base-dark-700",
"bg-base-light-400 dark:bg-base-dark-600": @selected_item.id == item.id,
@ -133,7 +139,7 @@ defmodule AshHqWeb.Components.Search do
{raw(item.search_headline)}
</div>
</div>
</LivePatch>
</button>
{/for}
"""
end
@ -247,6 +253,10 @@ defmodule AshHqWeb.Components.Search do
end
end
def handle_event("go-to-doc", %{"link" => doc_link}, socket) do
{:noreply, push_redirect(socket, to: doc_link)}
end
def handle_event("go-to-doc", _, socket) do
case Enum.find(socket.assigns.item_list, fn item ->
item.id == socket.assigns.selected_item.id

View file

@ -33,8 +33,8 @@ defmodule AshHq.MixProject do
# Type `mix help deps` for examples and options.
defp deps do
[
# {:ash, "~> 2.0.0-rc.5"},
{:ash, path: "../ash", override: true},
{:ash, "~> 2.0.0-rc.7"},
# {:ash, path: "../ash", override: true},
# {:ash_postgres, "~> 1.0.0-rc.3"},
{:ash_postgres, github: "ash-project/ash_postgres"},
# {:ash_postgres, path: "../ash_postgres"},
@ -70,7 +70,6 @@ defmodule AshHq.MixProject do
{:ecto_psql_extras, "~> 0.6"},
# Phoenix/Core dependencies
{:phoenix, "~> 1.6.6"},
{:phoenix_ecto, "~> 4.4"},
{:ecto_sql, "~> 3.6"},
{:postgrex, ">= 0.0.0"},
{:phoenix_html, "~> 3.0"},

View file

@ -1,10 +1,10 @@
%{
"absinthe": {:hex, :absinthe, "1.7.0", "36819e7b1fd5046c9c734f27fe7e564aed3bda59f0354c37cd2df88fd32dd014", [:mix], [{:dataloader, "~> 1.0.0", [hex: :dataloader, repo: "hexpm", optional: true]}, {:decimal, "~> 1.0 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: true]}, {:nimble_parsec, "~> 0.5 or ~> 1.0", [hex: :nimble_parsec, repo: "hexpm", optional: false]}, {:telemetry, "~> 1.0 or ~> 0.4", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "566a5b5519afc9b29c4d367f0c6768162de3ec03e9bf9916f9dc2bcbe7c09643"},
"absinthe_plug": {:hex, :absinthe_plug, "1.5.8", "38d230641ba9dca8f72f1fed2dfc8abd53b3907d1996363da32434ab6ee5d6ab", [:mix], [{:absinthe, "~> 1.5", [hex: :absinthe, repo: "hexpm", optional: false]}, {:plug, "~> 1.4", [hex: :plug, repo: "hexpm", optional: false]}], "hexpm", "bbb04176647b735828861e7b2705465e53e2cf54ccf5a73ddd1ebd855f996e5a"},
"ash": {:hex, :ash, "2.0.0-rc.5", "f5f852415d31d0f9624fd7510429abd7d3c5e271f23e553a8bdba01cf8d1df42", [:mix], [{:comparable, "~> 1.0", [hex: :comparable, repo: "hexpm", optional: false]}, {:decimal, "~> 2.0", [hex: :decimal, repo: "hexpm", optional: false]}, {:earmark, "~> 1.4", [hex: :earmark, repo: "hexpm", optional: true]}, {:ecto, "~> 3.7", [hex: :ecto, repo: "hexpm", optional: false]}, {:ets, "~> 0.8.0", [hex: :ets, repo: "hexpm", optional: false]}, {:jason, ">= 1.0.0", [hex: :jason, repo: "hexpm", optional: false]}, {:nimble_options, "~> 0.4.0", [hex: :nimble_options, repo: "hexpm", optional: false]}, {:picosat_elixir, "~> 0.2", [hex: :picosat_elixir, repo: "hexpm", optional: false]}, {:spark, "~> 0.1 and >= 0.1.9", [hex: :spark, repo: "hexpm", optional: false]}, {:stream_data, "~> 0.5.0", [hex: :stream_data, repo: "hexpm", optional: false]}, {:telemetry, "~> 1.1", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "93a272f0fd7c73189dfdb19221c9a2099a5bf9ab0dd11c26bd462a670d18d390"},
"ash_graphql": {:git, "https://github.com/ash-project/ash_graphql.git", "b2b9e22f7cfc70d48ec5beba46b5d588ea9e247b", []},
"ash_phoenix": {:git, "https://github.com/ash-project/ash_phoenix.git", "b64cd1394137713d1b407b49264fe88b3b7b6ebf", []},
"ash_postgres": {:git, "https://github.com/ash-project/ash_postgres.git", "11561ea163f60a4b32ee895b36005be24c8ab3d4", []},
"ash": {:hex, :ash, "2.0.0-rc.7", "5e75f13034b6d3cbfbb0e4c0e3cadfbb6b391bdf08db47294a328be885bb22cb", [:mix], [{:comparable, "~> 1.0", [hex: :comparable, repo: "hexpm", optional: false]}, {:decimal, "~> 2.0", [hex: :decimal, repo: "hexpm", optional: false]}, {:earmark, "~> 1.4", [hex: :earmark, repo: "hexpm", optional: true]}, {:ecto, "~> 3.7", [hex: :ecto, repo: "hexpm", optional: false]}, {:ets, "~> 0.8.0", [hex: :ets, repo: "hexpm", optional: false]}, {:jason, ">= 1.0.0", [hex: :jason, repo: "hexpm", optional: false]}, {:nimble_options, "~> 0.4.0", [hex: :nimble_options, repo: "hexpm", optional: false]}, {:picosat_elixir, "~> 0.2", [hex: :picosat_elixir, repo: "hexpm", optional: false]}, {:spark, "~> 0.1 and >= 0.1.9", [hex: :spark, repo: "hexpm", optional: false]}, {:stream_data, "~> 0.5.0", [hex: :stream_data, repo: "hexpm", optional: false]}, {:telemetry, "~> 1.1", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "dbff72557272e390a8ebeb879406d7e2dd93418093939ea778afdb7a8d5dc80c"},
"ash_graphql": {:git, "https://github.com/ash-project/ash_graphql.git", "b4dc207ed8834840c049c5baff65c53b3fc0a598", []},
"ash_phoenix": {:git, "https://github.com/ash-project/ash_phoenix.git", "75f07d12358b3473c4780c51333ef44aedf4c839", []},
"ash_postgres": {:git, "https://github.com/ash-project/ash_postgres.git", "0fa1ee05f4a6ba5461394dfef096ed8f9c1ada57", []},
"bcrypt_elixir": {:hex, :bcrypt_elixir, "3.0.1", "9be815469e6bfefec40fa74658ecbbe6897acfb57614df1416eeccd4903f602c", [:make, :mix], [{:comeonin, "~> 5.3", [hex: :comeonin, repo: "hexpm", optional: false]}, {:elixir_make, "~> 0.6", [hex: :elixir_make, repo: "hexpm", optional: false]}], "hexpm", "486bb95efb645d1efc6794c1ddd776a186a9a713abf06f45708a6ce324fb96cf"},
"bunt": {:hex, :bunt, "0.2.1", "e2d4792f7bc0ced7583ab54922808919518d0e57ee162901a16a1b6664ef3b14", [:mix], [], "hexpm", "a330bfb4245239787b15005e66ae6845c9cd524a288f0d141c148b02603777a5"},
"castore": {:hex, :castore, "0.1.18", "deb5b9ab02400561b6f5708f3e7660fc35ca2d51bfc6a940d2f513f89c2975fc", [:mix], [], "hexpm", "61bbaf6452b782ef80b33cdb45701afbcf0a918a45ebe7e73f1130d661e66a06"},

View file

@ -8,10 +8,11 @@ defmodule AshHq.Repo.Migrations.InstallPgStatStatements do
use Ecto.Migration
def up do
execute("CREATE EXTENSION IF NOT EXISTS \"pg_stat_statements\"")
# had to uncomment because fly.io doesn't allow
# execute("CREATE EXTENSION IF NOT EXISTS \"pg_stat_statements\"")
end
def down do
execute("DROP EXTENSION IF EXISTS \"pg_stat_statements\"")
# execute("DROP EXTENSION IF EXISTS \"pg_stat_statements\"")
end
end

View file

@ -8,10 +8,11 @@ defmodule AshHq.Repo.Migrations.InstallSslinfo do
use Ecto.Migration
def up do
execute("CREATE EXTENSION IF NOT EXISTS \"sslinfo\"")
# Removed because fly does not support this
# execute("CREATE EXTENSION IF NOT EXISTS \"sslinfo\"")
end
def down do
execute("DROP EXTENSION IF EXISTS \"sslinfo\"")
# execute("DROP EXTENSION IF EXISTS \"sslinfo\"")
end
end