~jack/casaaaaa

e2a9596fe18bef20b763b1a1221f62c8d4888750 — Jack Kelly 2 years ago 3345962
preventDefault the form submit
1 files changed, 11 insertions(+), 2 deletions(-)

M Main.hs
M Main.hs => Main.hs +11 -2
@@ 20,13 20,14 @@
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TemplateHaskell #-}

module Main where

import Control.Applicative (liftA2)
import Control.Category ((>>>))
import Control.Lens
import Control.Lens.Operators
import Control.Monad.Fix (MonadFix)
import Control.Monad.IO.Class (MonadIO)
import Data.Aviation.Casa.AbbreviationsAndAcronyms.Acronym


@@ 37,6 38,7 @@ import qualified Data.Aviation.Casa.AbbreviationsAndAcronyms.Search as Search
import Data.Foldable (for_)
import qualified Data.List.NonEmpty as NE
import qualified Data.Map as Map
import Data.Proxy (Proxy (..))
import Data.Text (Text)
import qualified Data.Text as T
import Data.Witherable (filter)


@@ 78,7 80,7 @@ body =
        el "h2" $ text "CASA Abbreviations And Acronyms Assistant"

    (searchTermD, searchFuncD) <-
      divClass "container" . el "form" $
      divClass "container" . form $
        liftA2 (,) searchWidget searchFuncWidget

    networkView $ do


@@ 112,6 114,13 @@ body =

    pure ()

form :: forall t m a. DomBuilder t m => m a -> m a
form children =
  let config =
        (def :: ElementConfig EventResult t (DomBuilderSpace m))
          & elementConfig_eventSpec %~ addEventSpecFlags (Proxy :: Proxy (DomBuilderSpace m)) Submit (const preventDefault)
   in snd <$> element "form" config children

searchWidget ::
  ( DomBuilder t m,
    MonadFix m,