Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Collapsible form #28

Merged
merged 18 commits into from
Sep 23, 2024
Merged

Collapsible form #28

merged 18 commits into from
Sep 23, 2024

Conversation

Peter9192
Copy link
Member

@Peter9192 Peter9192 commented Sep 17, 2024

Closes #7

Uses solidui accordion

Preview:

image

@Peter9192
Copy link
Member Author

I can't figure out how to add a transition when the width of the dialog changes as you collapse/expand sections

@Peter9192 Peter9192 marked this pull request as ready for review September 17, 2024 12:20
@Peter9192
Copy link
Member Author

Todo: check that form state is preserved when collapsed

@Peter9192 Peter9192 marked this pull request as draft September 18, 2024 10:02
@Peter9192
Copy link
Member Author

Todo: check that form state is preserved when collapsed

It is not. Need to make that work.

@sverhoeven
Copy link
Collaborator

sverhoeven commented Sep 19, 2024

Todo: check that form state is preserved when collapsed

It is not. Need to make that work.

Uncontrolled (aka no listener for onchange) inputs are used and content of a collapsed thing is not part of dom.
We could do

  1. Use <details><summary>Title</summary>Content</details>, so content is always rendered, pro uses native key binding, con need to control only 1 open
  2. Use controlled inputs, so any change to input is captured in a signal/store/form library outside of the dom. To avoid prop drilling use https://docs.solidjs.com/reference/component-apis/create-context
details example
 <form
        onSubmit={(e) => {
          e.preventDefault()
          e.stopPropagation()
          const f = new FormData(e.currentTarget)
          const r = Object.fromEntries(f.entries())
          console.log(r)
        }}
      >
        <details>
          <summary>Bla</summary>
          <input name="foo" value="bar"/>
          </details>
          <button type="submit">N</button>
        </form>

foo:bar is reported in devtools console

Styling see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/details

@sverhoeven
Copy link
Collaborator

Would be nice if the first accordion would be open initially. Use defaultValue prop.

@sverhoeven
Copy link
Collaborator

Todo: check that form state is preserved when collapsed

It is not. Need to make that work.

Uncontrolled (aka no listener for onchange) inputs are used and content of a collapsed thing is not part of dom. We could do

  1. Use <details><summary>Title</summary>Content</details>, so content is always rendered, pro uses native key binding, con need to control only 1 open
  2. Use controlled inputs, so any change to input is captured in a signal/store/form library outside of the dom. To avoid prop drilling use https://docs.solidjs.com/reference/component-apis/create-context

details example

Going for controlled inputs with modular forms

@sverhoeven
Copy link
Collaborator

The input fields are a bit close together, please add some whitespace above/below

@Peter9192
Copy link
Member Author

Peter9192 commented Sep 20, 2024

I believe the behaviour is okay now.

To do:

  • Fix types etc
  • [x] Better integrate kobalte/solidui/modularforms into textfield Spin off form generator to own package? #36
  • Now get warning "Cannot mutate a Store directly", fix that
  • Add whitespace between fields
  • One more go at animated width made dialog wider so less needed

@Peter9192
Copy link
Member Author

Currently only works for reference. Similar changes should be made to the permutations config. @sverhoeven you were considering to merge the two once they share the name field again. Are you still planning to do that in #27? Then I won't do it here.

Base automatically changed from 24-permutations to main September 23, 2024 09:30
@Peter9192 Peter9192 marked this pull request as ready for review September 23, 2024 10:43
@Peter9192 Peter9192 merged commit bcea8b2 into main Sep 23, 2024
4 checks passed
@Peter9192 Peter9192 deleted the collapsible-form branch September 23, 2024 10:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Settings form with tabs or collapsibles
2 participants