Skip to content

Commit 748ab20

Browse files
committed
prevent default form submit action
1 parent 72ce559 commit 748ab20

File tree

3 files changed

+21
-31
lines changed

3 files changed

+21
-31
lines changed

ghcjs/delivery-calculator/src/App/Widgets/Menu.hs

Lines changed: 15 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -139,14 +139,10 @@ menu st =
139139
}
140140
Currency.Args
141141
{ Currency.argsModel = st,
142-
Currency.argsOptic =
143-
#modelState . #stAssetCurrency,
144-
Currency.argsAction =
145-
PushUpdate . Instant,
146-
Currency.argsEmitter =
147-
pushActionQueue st . Instant,
148-
Currency.argsCurrencies =
149-
#modelCurrencies
142+
Currency.argsOptic = #modelState . #stAssetCurrency,
143+
Currency.argsAction = PushUpdate . Instant,
144+
Currency.argsEmitter = pushActionQueue st . Instant,
145+
Currency.argsCurrencies = #modelCurrencies
150146
}
151147
<> Currency.selectCurrency
152148
Currency.defOpts
@@ -155,40 +151,28 @@ menu st =
155151
}
156152
Currency.Args
157153
{ Currency.argsModel = st,
158-
Currency.argsOptic =
159-
#modelState . #stMerchantCurrency,
160-
Currency.argsAction =
161-
PushUpdate . Instant,
162-
Currency.argsEmitter =
163-
pushActionQueue st . Instant,
164-
Currency.argsCurrencies =
165-
#modelCurrencies
154+
Currency.argsOptic = #modelState . #stMerchantCurrency,
155+
Currency.argsAction = PushUpdate . Instant,
156+
Currency.argsEmitter = pushActionQueue st . Instant,
157+
Currency.argsCurrencies = #modelCurrencies
166158
}
167159
<> [ Select.select
168-
( Select.defOpts
169-
& #optsLabel
170-
.~ Just "Exchange rate"
160+
( Select.defOpts & #optsLabel .~ Just "Exchange rate"
171161
)
172162
Select.Args
173-
{ Select.argsModel =
174-
st,
175-
Select.argsOptic =
176-
#modelState . #stOnlineOrOffline,
177-
Select.argsAction =
178-
PushUpdate . Instant,
163+
{ Select.argsModel = st,
164+
Select.argsOptic = #modelState . #stOnlineOrOffline,
165+
Select.argsAction = PushUpdate . Instant,
179166
Select.argsOptions =
180167
constTraversal $ enumerate @OnlineOrOffline
181168
}
182169
]
183170
<> Field.ratioField
184171
Field.Args
185172
{ Field.argsModel = st,
186-
Field.argsOptic =
187-
#modelState . #stExchangeRate,
188-
Field.argsAction =
189-
PushUpdate . Instant,
190-
Field.argsEmitter =
191-
pushActionQueue st . Instant
173+
Field.argsOptic = #modelState . #stExchangeRate,
174+
Field.argsAction = PushUpdate . Instant,
175+
Field.argsEmitter = pushActionQueue st . Instant
192176
}
193177
( let disabled =
194178
st

ghcjs/miso-functora/src/Functora/Miso/Prelude.hs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ module Functora.Miso.Prelude
22
( module X,
33
consoleLog,
44
role_,
5+
form_,
56
)
67
where
78

@@ -20,6 +21,7 @@ import Miso as X hiding
2021
close,
2122
consoleLog,
2223
for_,
24+
form_,
2325
view,
2426
)
2527
import qualified Miso
@@ -29,3 +31,6 @@ consoleLog = Miso.consoleLog . inspect @Unicode
2931

3032
role_ :: Unicode -> Attribute action
3133
role_ = textProp "role"
34+
35+
form_ :: [Attribute action] -> [View action] -> View action
36+
form_ attrs = Miso.form_ (action_ "javascript:void(0)" : attrs)

ghcjs/miso-functora/src/Functora/Miso/Widgets/Currency.hs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ selectCurrency
103103
& #optsExtraAttributes
104104
.~ [autofocus_ True]
105105
)
106+
<> [br_ mempty]
106107
<> currencyListWidget opts args
107108
}
108109
where

0 commit comments

Comments
 (0)