silverstripe / silverstripe-elemental

Create pages in Silverstripe CMS using content blocks
http://dna.co.nz
BSD 3-Clause "New" or "Revised" License
110 stars 115 forks source link

Add a block when clicking a button in the "Add Block" popover #340

Closed ScopeyNZ closed 6 years ago

ScopeyNZ commented 6 years ago

338 implements an "Add Block" popover. When the various block types shown in this popover are clicked, a block needs to be added to the relevant elemental area.

A/Cs

ScopeyNZ commented 6 years ago

@clarkepaul For accessibility do you think we should add an A/C to make the newly added block the next thing that you tab to?

clarkepaul commented 6 years ago

Tough one, you might want to be adding multiple blocks (one after the other). I'm thinking to remain within the popover, after selecting a new block. Happy to hear what others think. Agree it should be an AC though.

clarkepaul commented 6 years ago

Three options as I see it:

  1. Close the popover, focus moves to the "Add" button
  2. Close popover, focus moves to newly added block
  3. Keep popover open, focus is on popover ready for another block to be added

I took at look at a few examples from others and they didn't really consider this, although clicking through the experience feels quite intuitive if you go to the new block as you mentioned @ScopeyNZ (opt. 3).

ScopeyNZ commented 6 years ago

the experience feels quite intuitive if you go to the new block as you mentioned @ScopeyNZ (opt. 3).

This was my initial thought. To be honest I didn't consider the idea of even leaving the popover open after clicking to add a block.

ScopeyNZ commented 6 years ago

@raissanorth has done a "part 1" PR at #404. There's still a something that needs to be addressed:

Clicking "Add block" in the designs has it just adding the block ready for in-line editing (with some fancy animations)

mutation AddBlockMutation($blockType:Sting!, $afterBlockId:ID) {
    addBlock(
        Type: $blockType
        AfterBlockID: $afterBlockId
    ) {
        ID
        Title
        BlockSchema
        InlineEditable
        IsLiveVersion
        IsPublished
        Version
    }
}
robbieaverill commented 6 years ago

Sounds good to me. A custom mutation which takes in the block type makes sense to me. We can either push an optimistic update to the Apollo cache with the new block or refetch the blocks again in order to re-render the new one

clarkepaul commented 6 years ago

@ScopeyNZ For complex blocks like Forms, I think the user can add the block to the page first, then they need to click on the block to navigate away to edit it.

brynwhyman commented 6 years ago

Adding a file/banner block that's been created via the GridFeildDetailForm that's empty currently wont be able to be expanded. This could come up as part of this ticket.

https://github.com/silverstripe/silverstripe-elemental-bannerblock/issues/11 https://github.com/silverstripe/silverstripe-elemental-fileblock/issues/5

brynwhyman commented 6 years ago

Also, please attempt to reproduce #312 after resolving this issue - it's possible this work could unintentionally resolve it.

NightJar commented 6 years ago

Done, animations are not a thing however. PR https://github.com/dnadesign/silverstripe-elemental/pull/443