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

Columns: Width recalculation does not work correctly when number of columns is increased by more than 2 at once #58824

Closed
t-hamano opened this issue Feb 8, 2024 · 0 comments · Fixed by #59301
Assignees
Labels
[Block] Columns Affects the Columns Block [Status] In Progress Tracking issues with work in progress [Type] Bug An existing feature does not function as intended

Comments

@t-hamano
Copy link
Contributor

t-hamano commented Feb 8, 2024

Description

When the number of columns is changed in a Columns block, if the columns all have percentage widths, the sum of the widths of each column is recalculated to be exactly 100%. However, when the number of columns is increased by 2 or more, it doesn't seem to be completely 100%.

So it looks like the current logic only takes into account the case where the number of columns increases by 1.

For example, assume that each of the four columns has the following widths:

| 20% | 30% | 30% | 20% |

✅ Correct: When the number of columns increases from 4 to 5

| 16% | 24% | 24% | 16% | 20% |

Total: 100%

✅ Correct: When the number of columns is reduced from 4 to 3

| 25% | 37.5% | 37.5% |

Total: 100%

✅ Correct: When the number of columns is reduced from 4 to 2

| 40% | 60% |

Total: 100%

❌ Wrong: When the number of columns increases from 4 to 6

| 16.67% | 25% | 25% | 16.67% | 16.67% | 16.67% |

Total: 116.68%

Step-by-step reproduction instructions

  • Insert a Columns block.
  • Set percentage widths for all columns so that they add up to 100%.
  • Select the Columns block and increase the number of columns by two or more without using the slider.
  • Calculate the total percentage width of each Column block.

Screenshots, screen recording, code snippet

No response

Environment info

No response

Please confirm that you have searched existing issues in the repo.

Yes

Please confirm that you have tested with all plugins deactivated except Gutenberg.

Yes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Block] Columns Affects the Columns Block [Status] In Progress Tracking issues with work in progress [Type] Bug An existing feature does not function as intended
Projects
None yet
1 participant