gutenberg icon indicating copy to clipboard operation
gutenberg copied to clipboard

Prevent deleting blocks entirely when removing columns

Open amjadr360 opened this issue 8 years ago • 31 comments

Describe the bug Whenever I change 3 columns into 2 the 3rd one gets eliminated along with its content. Instead 3rd column content should shift into next row. I can get my 3rd column's content by doing undo but it is not a good approach and even I do undo Columns option sate stay on 2 and when I hit update 3rd column content get deleted.

Screenshots Here screen record. https://drive.google.com/file/d/1gAxuRi7FPFMKWwoDtMYlkpQxXP2F1Gjm/view?usp=sharing

To Reproduce Steps to reproduce the behavior:

  1. Go to 'edit post'
  2. Add three columns and add content inside all of them.
  3. Then change 3 columns to 2 columns
  4. You will see 3rd columns will eliminate along with its content.

Expected behavior Instead got eliminated 3rd column content should shift into next row.

Desktop (please complete the following information):

  • OS: [Windows]
  • Browser [Chrome, safari]

Additional context Wordpress Version 4.9.8 Gutenberg Version 3.5.0

amjadr360 avatar Aug 15 '18 09:08 amjadr360

Congratulations on open issue 1000! 🎉🎉🎉🎉

GhostPirateBob avatar Aug 15 '18 09:08 GhostPirateBob

Quick note to say that I can replicate this, see gif.

gutenberg_columns

Replicated on:

Desktop: OS: Mac Sierra 10.12.6 Browser: Chrome Version: 69.0.3497.100

Additional context Gutenberg 3.9

eddhurst avatar Sep 26 '18 12:09 eddhurst

An issue I see is if the expected behavior is to merge the disappearing column's contents with the last content is that all the content would pile up and make the UI a mess. Then ideally, if all the disappearing content gets piled up in the 2nd column, changing it back to 3 columns should also undo the piling up. This might complicate things.

I would like to suggest an alternative behavior: just make the disappearing column's content hidden but still there. In the scenario, when the column count is set from 3 to 2, the content of the 3rd column would just be hidden. Then when the column is brought back to 3, it would just be present again. It would be up to the user to move things around.

bfintal avatar Oct 25 '18 07:10 bfintal

I think this needs to be improved design-wise. Ideally removing a column is an explicit action (clicking a "x" or something like that) instead of a range input.

youknowriad avatar Feb 07 '19 08:02 youknowriad

Can I also add to this that the range input should be removed, as if it is set to 2, and I have content in both my columns, I can click on this input, and delete the value and then proceed to type a different number (3 for example).

The result I am left with, because I deleted the value of 2, is that ALL of my column content is deleted and lost.

ghost avatar Apr 04 '19 15:04 ghost

I have a similar issue: Example: There are 4 columns. The 3rd column may be completely empty. 'When now reducing the column count of the columns block, the 4th column should become the 3rd column. Instead, currently the 4th column is simply removed while retaining the 3rd empty column.

Additionally, a method for swapping or reordering the columns would be a nice addition.

strarsis avatar May 03 '19 16:05 strarsis

in support of @leecollings:

Describe the bug

When we alter the number of columns using the input instead of the slider the content is not saved.

To reproduce

Steps to reproduce the behavior:

  • In a post or page
  • Add a column block
  • Write some text in both blocks -Select the columns block
  • Modify the number of columns in the inspector by changing the number in the input, instead of the slider, e.g. instead of 2, delete 2 and write 3
  • Content is gone.

Expected behavior

To behave like the slider:

  • If I am adding columns the content remains
  • If I am removing the content is deleted RTL
  • If I add the same number the content is saved

IMG_0126

draganescu avatar May 21 '19 07:05 draganescu

I think part of the problem here is I expect the columns to act like a grid — if I have three columns of content and reduce that number to two, I expect that third column to drop down into a new row beneath the top-left column. If I then set my columns back up to three, I expect that dropped column to flow back up into the original row:

image

Edit: Maybe we just need a grid block?

melchoyce avatar Jun 02 '19 22:06 melchoyce

Grid block sounds interesting!

msdesign21 avatar Jun 03 '19 20:06 msdesign21

I was able to replicate the disappearing content when reducing columns on WordPress 5.6 plain vanilla install with no plugins, on Chome Version 87.0.4280.141 (Official Build) (64-bit), and on the WordPress app, version alpha-266.

I think my mind expected it to work exactly as Mel described here. Would love to see that implemented!

aamills avatar Jan 19 '21 19:01 aamills

I've put together a PR (#34893) that should resolve this and it can be tested out at http://gutenberg.run/34893. I'd appreciate any feedback.

stokesman avatar Sep 21 '21 00:09 stokesman

This still exists and is exacerbated for Safari users by the Range Control bug https://github.com/WordPress/gutenberg/issues/32497 which makes it very easy to accidentally decrement the number of columns, losing data.

Expected behavior for me would be to preserve the content of the removed columns until save. If I save, it's not unreasonable to assume that I meant to also delete the contents of the removed column. Pre-save, though, I could have simply made a mistake.

@stokesman - i get "Invalid Pull Request" at http://gutenberg.run/34893.

sitetherapy avatar Feb 15 '22 21:02 sitetherapy

@sitetherapy, are you saying you are unable to restore the content by using undo? If that does work, I realize it's still far from ideal. Especially in combination with the bug from #32497.

Thanks for trying to test that PR and the heads up that it's no longer working. I guess with time PRs may become outdated and won't run on Gutenberg.run. I'd still like to revisit that PR but don't have much time lately.

stokesman avatar Feb 15 '22 21:02 stokesman

@stokesman - I can use the revisions to get back the content so undo might work (I'll try later) but for me the natural reaction was to increment the number of columns back to what it was.

My concern is two fold. One, that we have a bug that loses data and it's still open and two, while I can figure this out, I can't see asking a client to deal with this - "Oh yes, you lost data. Sorry about that. The block editor is kind of... not quite baked."

EDIT: Yes, Undo brings back the columns and their data, one undo per column deletion being needed, i.e. if you removed 2 columns, you need to choose Undo twice.

sitetherapy avatar Feb 16 '22 16:02 sitetherapy

@sitetherapy, thanks for confirming that undo works. As far as I can tell that's what has allowed this issue to languish. I've made PR #38840 for the (Safari) bug with the columns control so at least the potential to delete columns inadvertently can be lessened.

stokesman avatar Feb 16 '22 17:02 stokesman

The frustrating thing about this languishing is that, since Undo works, re-adding columns should also - the data is still there, just check for it when re-adding columns. It's completely natural to think "Oh dammit, I didnt mean to delete that column" and click to increment the column count back up, expecting the data to still be there. Hell, I did that and I'm technically savvy.

sitetherapy avatar Feb 16 '22 17:02 sitetherapy

As reported in https://github.com/WordPress/gutenberg/issues/47330 I suggest a very simple solution to reduce columns or make a complete undo of columns in a logical revert of Columns-creation from existing Blocks without any loss of content:

At start we have 4 regular blocks (could also be groups) in regular vertical layout: A B C D

Selecting them all and converting to a columns block results in new horizontal layout: A / B / C / D

Reducing our columns from 4 to 2 could - without any loss of content - result in a columns block and 2 regular blocks in vertical layout as before the creation of columns, by inserting the superfluous columns - from right to left, one by one - as regular content straight after the columns block: A / B C D

And a new command "Undo columns" extends this behaviour to the complete columns block and brings us - without any content change or tedious manual work - back to the start: A B C D

burnuser avatar Jan 23 '23 09:01 burnuser

Adding this to the Polish board as this definitely wears on the experience of those using the block editor, especially as layouts get more complex with the Site Editor. Marking as needs design for now as it doesn't quite seem as though we have a set determined way to move forward.

annezazu avatar Oct 22 '23 14:10 annezazu

Marking as needs design for now as it doesn't quite seem as though we have a set determined way to move forward.

Just noting that I'd prefer if the items in the Polish board are entirely actionable. Perhaps there shouldn't be "Needs design" issues at all to be honest. I don't think we have a clear way to handle this (although "Undo" does work here).

richtabor avatar Nov 23 '23 01:11 richtabor

Technically, would the solution be:

If I reduce the number of columns, the blocks within in the deleted columns are temporarily stored, to be restored if I increase the columns count again, in the same session?

richtabor avatar Jul 21 '24 17:07 richtabor