@@ -18,12 +18,10 @@ import Halogen.HTML.Properties as HP
18import Halogen.Query.EventSource as ES
18import Halogen.Query.EventSource as ES
19import Web.DOM.Document as Document
19import Web.DOM.Document as Document
20import Web.DOM.ParentNode as ParentNode
20import Web.DOM.ParentNode as ParentNode
21−import Web.HTML (window) as Web
22import Web.HTML as HTML
21import Web.HTML as HTML
23import Web.HTML.HTMLDocument as HTMLDocument
22import Web.HTML.HTMLDocument as HTMLDocument
24−import Web.HTML.HTMLElement (blur, focus) as Web
23+import Web.HTML.HTMLElement as HTMLElement
25import Web.HTML.HTMLInputElement as HTMLInputElement
24import Web.HTML.HTMLInputElement as HTMLInputElement
26−import Web.HTML.Window (document) as Web
27import Web.HTML.Window as Window
25import Web.HTML.Window as Window
28import Web.UIEvent.KeyboardEvent (KeyboardEvent)
26import Web.UIEvent.KeyboardEvent (KeyboardEvent)
29import Web.UIEvent.KeyboardEvent as KE
27import Web.UIEvent.KeyboardEvent as KE
@@ -78,7 +76,7 @@ handleAction = case _ of
79 InitKeyboardListener -> do
77 InitKeyboardListener -> do
81− document <- H.liftEffect $ Web.document =<< Web.window
79+ document <- H.liftEffect $ Window.document =<< HTML.window
82 H.subscribe' \sid ->
80 H.subscribe' \sid ->
83 ES.eventListenerEventSource
81 ES.eventListenerEventSource
@@ -92,14 +90,14 @@ handleAction = case _ of
92 when (not state.focused) do
90 when (not state.focused) do
93 H.liftEffect do
91 H.liftEffect do
94 withSearchField HTMLInputElement.select
92 withSearchField HTMLInputElement.select
95− withSearchField (HTMLInputElement.toHTMLElement >>> Web.focus)
93+ withSearchField (HTMLInputElement.toHTMLElement >>> HTMLElement.focus)
97 when (KE.code ev == "Escape") do
95 when (KE.code ev == "Escape") do
98 state <- H.get
96 state <- H.get
99 if state.focused
97 if state.focused
101 H.liftEffect do
99 H.liftEffect do
102− withSearchField (HTMLInputElement.toHTMLElement >>> Web.blur)
100+ withSearchField (HTMLInputElement.toHTMLElement >>> HTMLElement.blur)
103 else clearInput
101 else clearInput
105 InputAction input -> do
103 InputAction input -> do
@@ -108,16 +106,22 @@ handleAction = case _ of
108 EnterPressed -> do
106 EnterPressed -> do
109 state <- H.get
107 state <- H.get
110 H.liftEffect do
108 H.liftEffect do
111− withSearchField (HTMLInputElement.toHTMLElement >>> Web.blur)
109+ withSearchField (HTMLInputElement.toHTMLElement >>> HTMLElement.blur)
112 H.liftEffect (URIHash.setInput state.input)
110 H.liftEffect (URIHash.setInput state.input)
113 H.raise $ InputUpdated state.input
111 H.raise $ InputUpdated state.input
115− FocusChanged status -> do
113+ FocusChanged isFocused -> do
116− H.modify_ (_ { focused = status })
114+ H.modify_ (_ { focused = isFocused })
118− if status
116+ if isFocused
119 then Focused
117 then Focused
120 else LostFocus
118 else LostFocus
119+ when isFocused scrollToTop
121+scrollToTop :: H.HalogenM State Action () SearchFieldMessage Aff Unit
124+ HTML.window >>= Window.scroll 0 0
122clearInput :: H.HalogenM State Action () SearchFieldMessage Aff Unit
126clearInput :: H.HalogenM State Action () SearchFieldMessage Aff Unit
123clearInput = do
127clearInput = do