on master help sign in
Eliminate `title` for pushState
commit0459ed80d7d8bddd821d24e7232ce7bb10fcb920 authorRyan Trinkle <ryan.trinkle@gmail.com> dateWed 25 Jul 2018, 11:25 (8 years ago) parent2f4cb56
2 files changed+12−5
lib/frontend/src/Obelisk/Frontend.hs−2 lib/route/src/Obelisk/Route/Frontend.hs+12−3
lib/frontend/src/Obelisk/Frontend.hs−2
@@ -67,7 +67,6 @@ type ObeliskWidget t x route m =
6767data Frontend route = Frontend
6868 { _frontend_head :: !(forall t m x. ObeliskWidget t x route m => RoutedT t route m ())
6969 , _frontend_body :: !(forall t m x. ObeliskWidget t x route m => RoutedT t route m ())
70− , _frontend_title :: !(route -> Text)
7170 , _frontend_notFoundRoute :: !(Text -> route) --TODO: Instead, maybe we should just require that the `parse` Monad for routeEncoder be `Identity`
7271 }
7372
@@ -144,7 +143,6 @@ runFrontend validFullEncoder frontend = do
144143 -> m a
145144 runMyRouteViewT = runRouteViewT
146145 ve
147− (_frontend_title frontend)
148146 (_frontend_notFoundRoute frontend)
149147 runWithHeadAndBody $ \appendHead appendBody -> runMyRouteViewT $ do
150148 mapRoutedT (mapEventWriterT appendHead) $ _frontend_head frontend
lib/route/src/Obelisk/Route/Frontend.hs+12−3
@@ -182,11 +182,10 @@ runRouteViewT
182182 , MonadFix m
183183 )
184184 => (ValidEncoder (Either Text) r PageName)
185− -> (r -> Text)
186185 -> (Text -> r) -- ^ 404 page
187186 -> RoutedT t r (EventWriterT t (Endo r) m) a
188187 -> m a
189−runRouteViewT routeValidEncoder routeToTitle error404 a = do
188+runRouteViewT routeValidEncoder error404 a = do
190189 rec historyState <- manageHistory $ HistoryCommand_PushState <$> setState
191190 let route :: Dynamic t r
192191 route = fmap (runIdentity . _validEncoder_decode (catchValidEncoder error404 $ pageNameValidEncoder . routeValidEncoder) . (uriPath &&& uriQuery) . _historyItem_uri) historyState
@@ -196,7 +195,17 @@ runRouteViewT routeValidEncoder routeToTitle error404 a = do
196195 (newPath, newQuery) = _validEncoder_encode (pageNameValidEncoder . routeValidEncoder) newRoute
197196 in HistoryStateUpdate
198197 { _historyStateUpdate_state = DOM.SerializedScriptValue jsNull
199− , _historyStateUpdate_title = routeToTitle newRoute
198+ -- We always provide "" as the title. On Firefox, Chrome, and
199+ -- Edge, this parameter does nothing. On Safari, "" has the
200+ -- same behavior as other browsers (as far as I can tell), but
201+ -- anything else sets the title for the back button list item
202+ -- the *next* time pushState is called, unless the page title
203+ -- is changed in the interim. Since the Safari functionality
204+ -- is near-pointless and also confusing, I'm not going to even
205+ -- bother exposing it; if there ends up being a real use case,
206+ -- we can change this function later to accommodate.
207+ -- See: https://github.com/whatwg/html/issues/2174
208+ , _historyStateUpdate_title = ""
200209 , _historyStateUpdate_uri = Just $ nullURI
201210 { uriPath = newPath
202211 , uriQuery = newQuery