Skip to content

Conversation

@tomycostantino
Copy link
Contributor

@tomycostantino tomycostantino commented Dec 9, 2025

Problem

When creating or destroying a column or moving it either right or left, the views/boards/show/menu/_column_form.html.erb partial of already existing columns is stale, so the action buttons inside the form are either disabled or actionable when should not be the case.

How to reproduce

  1. Create a new board and navigate to it.
  2. Create a new column.
  3. Create another column.
  4. Expand the first created column by clicking on it.
  5. Open the action menu by clicking on the ellipsis icon.
  6. The action button to move it right is disabled although it can be moved right.
  7. Delete the first created column.
  8. Expand the second created column.
  9. Open the action menu by clicking on it.
  10. The action button to move the column left is still enabled, even though there is nothing to the left side.

Demonstration video

screenrecording-2025-12-09_10-31-58.mp4

Solution

Refresh board columns on move right/left and create/destroy actions. I extracted the update logic into the views/columns/_refresh_surroundings.turbo_stream.erb which is rendered by other streams.

@tomycostantino tomycostantino changed the title Bug fix: board columns actions are stale when moving a column moves Fix: board columns actions are stale when moving a column moves Dec 9, 2025
Copy link
Member

@jorgemanrubia jorgemanrubia left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great one @tomycostantino 🙏. Some minor suggestions and a request for a change that can fix other related bug we have.

right_column.nil?
end

def surroundings
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor: I would rename to surrounding_columns or adjacent_columns, so that it is clear what this is returning.

@@ -1 +1,2 @@
<%= turbo_stream.remove(dom_id(@column)) %>
<%= turbo_stream.remove(dom_id(@column)) %>
<%= render "columns/refresh_surroundings", column: @column %>
Copy link
Member

@jorgemanrubia jorgemanrubia Dec 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have a bug where deleting a column won't show its cards automatically in the Maybe column. We could get rid of the destroy turbo stream action and replace with just a redirect_back_or_to @board, so that a full page morph will take care of the problem. If you are happy to tackle that here, we can fix that bug as part of this PR 🙏. We can remove the destroy stream action and replace with the redirect.

@@ -0,0 +1,4 @@
<% column.surroundings.each do |surrounding| %>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Related to my feedback above: I'd rather see surrounding_column or adjacent_column than just surrounding.


before_create :set_position
after_create_commit -> { surroundings.touch_all }
after_destroy_commit -> { surroundings.touch_all }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need this explicit invalidation? In theory we consider adjacent columns for caching here:

<%= render partial: "boards/show/column", collection: board.columns.sorted, cached: ->(column){ [ column, column.leftmost?, column.rightmost? ] } %>

@tomycostantino
Copy link
Contributor Author

Hey @jorgemanrubia thank you for reviewing! Just made the changes you've requested, and fixed the bug referenced in the issue. Here's how it looks:

screenrecording-2025-12-11_10-49-52.mp4

Copy link
Member

@jorgemanrubia jorgemanrubia left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fantastic @tomycostantino thanks

@jorgemanrubia jorgemanrubia merged commit d7e5d42 into basecamp:main Dec 14, 2025
4 checks passed
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.

2 participants