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

Block: Contact Form Improvements #15286

Closed
8 of 9 tasks
apeatling opened this issue Apr 3, 2020 · 25 comments · Fixed by #15362
Closed
8 of 9 tasks

Block: Contact Form Improvements #15286

apeatling opened this issue Apr 3, 2020 · 25 comments · Fixed by #15362
Assignees
Labels
Blocks V2 [Feature] Contact Form [Focus] Blocks Issues related to the block editor, aka Gutenberg, and its extensions developed in Jetpack [Type] Enhancement Changes to an existing feature — removing, adding, or changing parts of it
Milestone

Comments

@apeatling
Copy link
Member

apeatling commented Apr 3, 2020

Current visual state:

Screen Shot 2020-04-03 at 1 09 23 PM

Improvements to make for this block via @mtias

  • Update to support the block variations API so that we don't need to offer a generic "Form" block and provide a number of more specific uses in the inserter.
  • We should make the owner’s email address and the subject line for the messages received part of the toolbar.
  • Provide a default fallback email address as the site admin email address.
  • The input fields for the labels look to jump a bit on selection.
  • There are some “field settings” in the sidebar inspector for the child blocks but with no context or helpful text to guide you.
  • Adding text to the “default value” field doesn’t seem to do anything on the block render either.
  • We should avoid the “required” toggle in the block canvas. It can be placed in the toolbar instead, and upon toggling it can render the red “required” immediately.
  • The “submit” button cannot be aligned differently than the default (to the left) and is not a separate child block. See: [Experiment] Blocks: Add a new shared Button block #15370
  • Build some nice block patterns for it and ensure we have enough customization options to handle visual variety.

@iamtakashi @pablohoneyhoney I think we have a few examples of patterns for the contact form, if we can drop those here that would be 👍👍, thanks.

@apeatling apeatling added [Type] Enhancement Changes to an existing feature — removing, adding, or changing parts of it [Feature] Contact Form [Focus] Blocks Issues related to the block editor, aka Gutenberg, and its extensions developed in Jetpack Blocks V2 labels Apr 3, 2020
@apeatling apeatling self-assigned this Apr 3, 2020
@mtias
Copy link
Member

mtias commented Apr 4, 2020

Update to support the block variations API so that we don't need to offer a generic "Form" block and provide a number of more specific uses in the inserter.

For this I was thinking we could explore keeping the base block as "Form" but we hide it form the inserter (inserter: false) and then register the different forms we want to expose as variations: Contact Form, Feedback, etc.

Alternatively, we keep Form exposed but we use the variations system to ensure Contact Form etc employ the scope mechanism scope: [ 'block', 'inserter' ] to ensure it can be selected when inserter the generic "Form".

@apeatling
Copy link
Member Author

apeatling commented Apr 7, 2020

I think the first one is best, but I don't think we can hide the generic form in the inserter until variations show up in the / inserter WordPress/gutenberg#20583. Until then we could expose them in the regular inserter, and also via the block when selecting the generic Form base block?

@apeatling
Copy link
Member Author

I've added support for variations to #15362 that includes a variation selection screen when the base Form block is selected, but also includes the variations in the picker.

@apeatling
Copy link
Member Author

apeatling commented Apr 10, 2020

We should avoid the “required” toggle in the block canvas. It can be placed in the toolbar instead, and upon toggling it can render the red “required” immediately.

@mtias Do you see this as a toggle embedded within the toolbar, or a button that shows a dropdown with the toggle option?

@apeatling
Copy link
Member Author

As a bonus, I've also added support for padding and space between fields from single controls in the parent block.

@apeatling
Copy link
Member Author

We should avoid the “required” toggle in the block canvas. It can be placed in the toolbar instead, and upon toggling it can render the red “required” immediately.

I've removed this from the canvas and added it to the sidebar. I'm happy to add it to the toolbar, but having a dropdown with a single toggle seems odd to me. If the toggle can be embedded within the actual toolbar that seems better, but I don't think there is any precedent for this?

@mtias
Copy link
Member

mtias commented Apr 15, 2020

Yes, I meant a toggle embedded in the toolbar directly. If there was a clear enough icon with a tooltip, it could be just a regular toolbar button action, as most icon-buttons already work as toggles (like bold) in the toolbar.

@mtias
Copy link
Member

mtias commented Apr 15, 2020

Wonder how you think we could make something like this possible (or if we should) as well:

image

(With labels instead of placeholder text.)

@apeatling
Copy link
Member Author

Yes, I meant a toggle embedded in the toolbar directly. If there was a clear enough icon with a tooltip, it could be just a regular toolbar button action, as most icon-buttons already work as toggles (like bold) in the toolbar.

Added this to the toolbar. It's hard to find the right icon, but I'd like all the icons I've added in the PR to get a review and update once everything is working.

2020-04-19 11 27 17

@apeatling
Copy link
Member Author

apeatling commented Apr 19, 2020

Wonder how you think we could make something like this possible (or if we should) as well:

@mtias I think this could be useful for design patterns and be a toggle option in the parent block that applies to all fields? "Include labels in fields?" or something like this?

Edit -- just noticed your comment right at the bottom. You mean the multi-columns and not the labels?

@iamtakashi
Copy link
Contributor

I dislike the default width of the input fields set by the block for the front of the site. I find it odd :)

Frame 1

For a stack layout like the screenshot above, I'd prefer 100% width.

Frame 1-b

cc @ianstewart @alaczek (Since this came up in our chat before.)

@apeatling
Copy link
Member Author

apeatling commented Apr 23, 2020

@iamtakashi Already done 😀

@pablohoneyhoney
Copy link

2020-04-19 11 27 17

It'd be good to update the block icon, and find a different icon for required if this is the preferred interaction (curious if you think this is more of a sidebar function).

@apeatling
Copy link
Member Author

apeatling commented Apr 27, 2020

It'd be good to update the block icon, and find a different icon for required if this is the preferred interaction (curious if you think this is more of a sidebar function).

I agree, the icons in this block in general are not good so I'd like to review those as a whole. I think the preferred interaction is via the sidebar and that will stay as it is, the toolbar icon was added because I believe the pattern is now for primary interactions on a block to be in the block toolbar. @pablohoneyhoney Would you be willing to come up with a better icon here?

@mtias
Copy link
Member

mtias commented Apr 28, 2020

just noticed your comment right at the bottom. You mean the multi-columns and not the labels?

Yes, the multi column. Like @iamtakashi mentions, I think by default it should be full-width, but it should be possible to say you want 50% on a field and they would stack in columns.

(This should not be a blocker for a first pass, just something to consider later.)

@alaczek
Copy link
Contributor

alaczek commented Apr 29, 2020

The multi-column option would open up some cool design possibilities! I saw something similar done, can't remember where exactly, for the Name field specifically. This was done with a radio toggle setting to split up the Name field into first and last name, and those two fields would be then displayed side-by-side.

@apeatling
Copy link
Member Author

apeatling commented May 1, 2020

@alaczek This is how CoBlocks handles it. It's a simple way to handle splitting the name field into two columns inside of a single block using flexbox.

I think we'd want to go much further than this. My first thought was to use flexbox in the same way and auto arrange field blocks into columns with a simple column count slider. It would be the most straightforward for the user, just slide the toggle to adjust column count and you're done. I think this would break down quickly though -- you would not be able to move fields, block UI would be affected, and inserting new fields in a specific location almost impossible. I think it's a non starter.

I do like the idea of having a column count slider to auto arrange fields, from a UX perspective it's incredibly simple. If this could be combined with intelligently arranging blocks inside and outside of columns blocks then you could retain a simple interaction backed by the power of columns. That would allow users the ability to add, remove, and rearrange field blocks after selecting their column count.

/cc @mtias

@apeatling
Copy link
Member Author

Tried the above using the columns block and confirmed it works. This is a basic example with two standard input fields being placed in a two column block leaving the textarea field spanning both columns:

2020-05-03 13 54 32

I'll expand on this and see how I can handle more columns and more fields.

@mtias
Copy link
Member

mtias commented May 4, 2020

I am not sure a column attribute would be the best — would you expect "message" to be a allocated to a column? What happens with other fields? My thinking was more like this: flex would be set by default, with the fields set to 100%; changing two subsequent ones to 50% (name and email) would yield the result above.

It could use the following component from the Image block:
image

@apeatling
Copy link
Member Author

I am not sure a column attribute would be the best — would you expect "message" to be a allocated to a column? What happens with other fields?

My thought would be to provide an option for textarea fields to span columns (or not). Let me try working with flex using the component you mentioned. I think this is more fiddly but does give you greater control.

@mtias
Copy link
Member

mtias commented May 4, 2020

I think it might also be something people access mainly through patterns rather than setting them up themselves.

@apeatling
Copy link
Member Author

Yes agreed. I was thinking end users and simplicity, but this is about pattern building so that finer grained control makes sense here.

@mtias
Copy link
Member

mtias commented May 4, 2020

If you think you can get to something that feels pretty intuitive, flexible, and easy to control, it might still be worth to explore!

@apeatling
Copy link
Member Author

The flexbox approach works well, I think this is actually simple enough. Here's a preview of this working, I'll push a PR up soon for it.

2020-05-04 14 53 58

@apeatling
Copy link
Member Author

Opened a draft PR with these changes here: #15674. Will keep this separate to not block the other contact form updates from merging first.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Blocks V2 [Feature] Contact Form [Focus] Blocks Issues related to the block editor, aka Gutenberg, and its extensions developed in Jetpack [Type] Enhancement Changes to an existing feature — removing, adding, or changing parts of it
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants