Skip to content

Commit

Permalink
Remove form submission hack
Browse files Browse the repository at this point in the history
This was needed due to a cyclejs bug that is now fixed
in @cycle/dom v22.6.0 by cyclejs/cyclejs#906

This also fixes some bugs in other forms that didn't implement the hack,
like the push transaction form which didn't work after hitting 'back'.

Also see cyclejs/cyclejs#853
  • Loading branch information
shesek committed Mar 24, 2020
1 parent 6b5b608 commit aceb4d1
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 30 deletions.
3 changes: 0 additions & 3 deletions HACKS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,2 @@
- @cycle/history had to be patched (via patch-package) to properly handle `<base href>`

- search form submissions were not properly caught by cyclejs's dom driver, had to be
worked around with a hack using rxjs directly.

25 changes: 7 additions & 18 deletions client/npm-shrinkwrap.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"dependencies": {
"@babel/plugin-transform-react-jsx": "^7.9.1",
"@babel/polyfill": "^7.8.7",
"@cycle/dom": "^22.4.0",
"@cycle/dom": "^22.6.0",
"@cycle/history": "^7.4.0",
"@cycle/html": "^3.3.0",
"@cycle/http": "^15.3.0",
Expand Down
11 changes: 3 additions & 8 deletions client/src/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,6 @@ const apiBase = (process.env.API_URL || '/api').replace(/\/+$/, '')

const reservedPaths = [ 'mempool', 'assets' ]

// Temporary bug workaround. Listening with on('form.search', 'submit') was unable
// to catch some form submissions.
const searchSubmit$ = !process.browser ? O.empty() : O.fromEvent(document.body, 'submit')
.filter(e => e.target.classList.contains('search'))

// Make driver source observables rxjs5-compatible via rxjs-compat
setAdapt(stream => O.from(stream))

Expand Down Expand Up @@ -59,6 +54,8 @@ export default function main({ DOM, HTTP, route, storage, scanner: scan$, search

, goAssetList$ = !process.env.ISSUED_ASSETS || !process.env.ASSET_MAP_URL ? O.empty() : route('/assets')

, searchSubmit$ = on('.search', 'submit').map(e => e.target.querySelector('[name=q]').value)

// auto-expand when opening with "#expand"
, expandTx$ = route('/tx/:txid').filter(loc => loc.query.expand).map(loc => loc.params.txid)
, expandBl$ = route('/block/:hash').filter(loc => loc.query.expand).map(loc => loc.params.hash)
Expand All @@ -68,7 +65,7 @@ export default function main({ DOM, HTTP, route, storage, scanner: scan$, search
, togTheme$ = click('.toggle-theme')

, copy$ = click('[data-clipboard-copy]').map(d => d.clipboardCopy)
, query$ = O.merge(searchSubmit$.map(e => e.target.querySelector('[name=q]').value), goSearch$)
, query$ = O.merge(searchSubmit$, goSearch$)
, pushtx$ = (process.browser
? on('form[data-do=pushtx]', 'submit', { preventDefault: true }).map(e => e.ownerTarget.querySelector('[name=tx]').value)
: goPush$.filter(loc => loc.body && loc.body.tx).map(loc => loc.body.tx)
Expand Down Expand Up @@ -361,8 +358,6 @@ export default function main({ DOM, HTTP, route, storage, scanner: scan$, search
// @XXX side-effects outside of drivers
if (process.browser) {

searchSubmit$.subscribe(e => e.preventDefault())

// Click-to-copy
if (navigator.clipboard) copy$.subscribe(text => navigator.clipboard.writeText(text))

Expand Down

0 comments on commit aceb4d1

Please sign in to comment.