Skip to content

Add new cards to top or bottom - #8181

Open
theoholl wants to merge 35 commits into
mainfrom
add-new-cards-to-top-or-bottom
Open

Add new cards to top or bottom#8181
theoholl wants to merge 35 commits into
mainfrom
add-new-cards-to-top-or-bottom

Conversation

@theoholl

@theoholl theoholl commented Jul 19, 2026

Copy link
Copy Markdown
Contributor

Summary

Users can now choose whether new cards are added to the top or the bottom of a list. A new setting in the Deck settings toggles the behavior; the 'Add card' button sits on the side of the list where the card will be inserted. The default behavior is unchanged (add to bottom).

Settings toggle for changing between adding cards to the top or the bottom of the stack:

image

Adding cards to the top of the stack:

image

Adding cards to the bottom of the stack:

image

Implementation notes

  • New per-user setting stackAddCardAtTop (ConfigService), exposed to the client via the initial state and toggled in the Deck settings.
  • The add-card form is extracted from Stack.vue into a new StackCardAdd.vue component and rendered above or below the card list depending on the setting.
  • CardService::create() gained an insertAtPosition flag: the card is inserted and the surrounding cards are shifted in a single DB transaction, so no follow-up reorder request is needed.
  • API behavior note: passing an explicit order to the OCS card create endpoint now inserts the card at that position and shifts the surrounding cards, instead of only storing the raw order value. Omitting order keeps the previous append-to-bottom behavior.
  • Covered by unit tests (transaction commit + rollback) and a Cypress test that verifies both modes and persistence across reloads.

Checklist

  • Code is properly formatted
  • Sign-off message is added to all commits
  • Documentation (manuals or wiki) has been updated or is not required

theoholl added 11 commits July 19, 2026 10:41
Signed-off-by: Theo <36564257+theoholl@users.noreply.github.com>
Signed-off-by: Theo <36564257+theoholl@users.noreply.github.com>
…but make it stick in visible area on overflow

Signed-off-by: Theo <36564257+theoholl@users.noreply.github.com>
Signed-off-by: Theo <36564257+theoholl@users.noreply.github.com>
…image` was cutting of dragged cards.

Signed-off-by: Theo <36564257+theoholl@users.noreply.github.com>
Signed-off-by: Theo <36564257+theoholl@users.noreply.github.com>
…or-bottom

# Conflicts:
#	src/components/board/Stack.vue
…s set to 'add to bottom'

Signed-off-by: Theo <36564257+theoholl@users.noreply.github.com>
Signed-off-by: Theo <36564257+theoholl@users.noreply.github.com>
Signed-off-by: Theo <36564257+theoholl@users.noreply.github.com>
Signed-off-by: Theo <36564257+theoholl@users.noreply.github.com>
@theoholl
theoholl marked this pull request as ready for review July 19, 2026 17:16
Signed-off-by: Theo <36564257+theoholl@users.noreply.github.com>
@theoholl
theoholl force-pushed the add-new-cards-to-top-or-bottom branch from e5aa08a to 050a23d Compare July 20, 2026 07:55
@theoholl
theoholl force-pushed the add-new-cards-to-top-or-bottom branch from f911c83 to 7d7651c Compare July 20, 2026 09:27
@github-actions

Copy link
Copy Markdown
Contributor

🐢 Performance warning.
It looks like the query count of the integration tests increased with this PR.
Database query count is now 96814 was 96706 (+0.11%)
Please check your code again. If you added a new test this can be expected and the base value in tests/integration/base-query-count.txt can be increased.

Signed-off-by: Theo <36564257+theoholl@users.noreply.github.com>
@theoholl
theoholl force-pushed the add-new-cards-to-top-or-bottom branch from 7d7651c to bcaea9d Compare July 20, 2026 09:42

@grnd-alt grnd-alt left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for your contribution!
I like the idea in general but I think the implementation is way to complex. For a sticky element like that we shouldn't need that much js, I don't think we need a resizeObserver and bottomAddCardInline for example. For the handling with empty stacks, we could only use the isEmptyStack and remove isEmptyStackWithBottomAddCard, please also have a look at the other js parts of this pr to simplify it further.

some ui things I noticed:

  • you can't really drag and drop to empty stacks as the dnd container shrinks
  • when clicking "add card" the input gets bigger/wider which causes a sudden layout shift, would be nice to not have that
  • subjective but I think having the "add card" with less opacity might look nicer to not draw away attention from the cards already there

@theoholl

Copy link
Copy Markdown
Contributor Author

Completely agreed, I'll work on that. Thanks for your review! :)

theoholl added 3 commits July 22, 2026 13:07
Signed-off-by: Theo <36564257+theoholl@users.noreply.github.com>
…op mode

Signed-off-by: Theo <36564257+theoholl@users.noreply.github.com>
Signed-off-by: Theo <36564257+theoholl@users.noreply.github.com>
@github-actions

Copy link
Copy Markdown
Contributor

🐢 Performance warning.
It looks like the query count of the integration tests increased with this PR.
Database query count is now 96846 was 96706 (+0.14%)
Please check your code again. If you added a new test this can be expected and the base value in tests/integration/base-query-count.txt can be increased.

theoholl added 3 commits July 26, 2026 17:05
Signed-off-by: Theo <36564257+theoholl@users.noreply.github.com>
…for add-to-bottom lists

Signed-off-by: Theo <36564257+theoholl@users.noreply.github.com>
Signed-off-by: Theo <36564257+theoholl@users.noreply.github.com>
Signed-off-by: Theo <36564257+theoholl@users.noreply.github.com>
@theoholl

Copy link
Copy Markdown
Contributor Author

Previously, I placed the 'Add card' button right underneath the last card of the stack and then sticking to the bottom of the board when the cards overflowed.

image

This had some disadvantages:

  • Most importantly, for me, this introduces unpredictable behavior because cards that were dragged in from another stack had to be dropped above the 'Add card' button which is different for add-cards-to-the-top stacks where one could drop off the card anywhere. This is especially confusing for users since there is no visible drop-off zone marked by a border or a background color.
  • That could be fixed by allowing cards to be dropped anywhere on the stack but without any visual feedback it feels weird dropping a card on an add-cards-to-bottom stack below the 'Add card' button, basically into a void.
  • Introducing visual feedback, e.g. making the 'Add card' button move down a bit to 'make room' for the new card when a card is moved onto the stack is also weird and perhaps one would want the same visual effect then for stacks with some cards on it?

I think those issues could be tackled with a clear 'drop box' like Trello.

image

But for now I would keep the exact same, predictable behaviour for add-to-top and add-to-bottom lists.

theoholl added 6 commits July 30, 2026 17:31
Signed-off-by: Theo <36564257+theoholl@users.noreply.github.com>
Signed-off-by: Theo <36564257+theoholl@users.noreply.github.com>
…or-bottom

# Conflicts:
#	src/components/board/Stack.vue
Signed-off-by: Theo <36564257+theoholl@users.noreply.github.com>
Signed-off-by: Theo <36564257+theoholl@users.noreply.github.com>
Signed-off-by: Theo <36564257+theoholl@users.noreply.github.com>
@github-actions

github-actions Bot commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

Hello there,
Thank you so much for taking the time and effort to create a pull request to our Nextcloud project.

We hope that the review process is going smooth and is helpful for you. We want to ensure your pull request is reviewed to your satisfaction. If you have a moment, our community management team would very much appreciate your feedback on your experience with this PR review process.

Your feedback is valuable to us as we continuously strive to improve our community developer experience. Please take a moment to complete our short survey by clicking on the following link: https://cloud.nextcloud.com/apps/forms/s/i9Ago4EQRZ7TWxjfmeEpPkf6

Thank you for contributing to Nextcloud and we hope to hear from you soon!

(If you believe you should not receive this message, you can add yourself to the blocklist.)

…or-bottom

# Conflicts:
#	src/components/board/Stack.vue
@github-actions

github-actions Bot commented Aug 8, 2026

Copy link
Copy Markdown
Contributor

🐢 Performance warning.
It looks like the query count of the integration tests increased with this PR.
Database query count is now 198590 was 198420 (+0.08%)
Please check your code again. If you added a new test this can be expected and the base value in tests/integration/base-query-count.txt can be increased.

Signed-off-by: Theo <36564257+theoholl@users.noreply.github.com>
@theoholl
theoholl force-pushed the add-new-cards-to-top-or-bottom branch from e212f79 to 7e606fa Compare August 8, 2026 18:47
@github-actions

github-actions Bot commented Aug 8, 2026

Copy link
Copy Markdown
Contributor

🐢 Performance warning.
It looks like the query count of the integration tests increased with this PR.
Database query count is now 200336 was 198420 (+0.96%)
Please check your code again. If you added a new test this can be expected and the base value in tests/integration/base-query-count.txt can be increased.

@github-actions

github-actions Bot commented Aug 8, 2026

Copy link
Copy Markdown
Contributor

🐢 Performance warning.
It looks like the query count of the integration tests increased with this PR.
Database query count is now 200402 was 198420 (+0.99%)
Please check your code again. If you added a new test this can be expected and the base value in tests/integration/base-query-count.txt can be increased.

…d form after creation

- Let CardService::create() decide when to reorder based on the requested
  order, so all card creation endpoints behave consistently.
- Close the inline add-card form after a card is successfully created to
  prevent it from covering the new card and fix flaky Cypress tests.

Signed-off-by: Theo <36564257+theoholl@users.noreply.github.com>
Inferring the reorder-on-insert behavior from `$order !== 999` broke
cloneCard() and DefaultBoardService, which call create() with real,
already-correct order values (e.g. 0) that must not trigger a shift of
other cards in the stack. Restore the explicit $insertAtPosition flag,
opted into only by the OCS controller used by the new add-card UI.

Signed-off-by: Theo <36564257+theoholl@users.noreply.github.com>
@github-actions

github-actions Bot commented Aug 8, 2026

Copy link
Copy Markdown
Contributor

🐢 Performance warning.
It looks like the query count of the integration tests increased with this PR.
Database query count is now 200865 was 198420 (+1.23%)
Please check your code again. If you added a new test this can be expected and the base value in tests/integration/base-query-count.txt can be increased.

@github-actions

github-actions Bot commented Aug 8, 2026

Copy link
Copy Markdown
Contributor

🐢 Performance warning.
It looks like the query count of the integration tests increased with this PR.
Database query count is now 200355 was 198420 (+0.97%)
Please check your code again. If you added a new test this can be expected and the base value in tests/integration/base-query-count.txt can be increased.

Signed-off-by: Theo <36564257+theoholl@users.noreply.github.com>
@github-actions

github-actions Bot commented Aug 8, 2026

Copy link
Copy Markdown
Contributor

🐢 Performance warning.
It looks like the query count of the integration tests increased with this PR.
Database query count is now 200345 was 198420 (+0.97%)
Please check your code again. If you added a new test this can be expected and the base value in tests/integration/base-query-count.txt can be increased.

- Name the sentinel order in CardOcsController instead of a magic 999
- Drop unreachable stackAddCardAtTop case from ConfigService::get()
- Restore the stronger visibility assertion in the label e2e test

Signed-off-by: Theo <36564257+theoholl@users.noreply.github.com>

@theoholl theoholl left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

A few implementation notes for reviewers.

$card = $this->cardMapper->insert($card);
} else {
// Insert at the requested position and shift the surrounding cards
$this->connection->beginTransaction();

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Insertion and order normalization are one transaction, so a failed reorder cannot leave the new card stored with conflicting positions.

stackId: this.stack.id,
boardId: this.stack.boardId,
// Without an order the API appends the card to the end of the stack
...(this.addAtTop ? { order: 0 } : {}),

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Bottom insertion deliberately omits order to preserve the existing append behavior. Top insertion sends order: 0; the server shifts the existing cards.

Comment thread src/stores/card.js
if (card.order !== undefined) {
for (const existingCard of this.cards) {
if (existingCard.stackId === createdCard.stackId && existingCard.order >= card.order) {
Vue.set(existingCard, 'order', existingCard.order + 1)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Mirror the server-side shift locally so the new top card renders in the correct position immediately after creation.

@github-actions

github-actions Bot commented Aug 8, 2026

Copy link
Copy Markdown
Contributor

🐢 Performance warning.
It looks like the query count of the integration tests increased with this PR.
Database query count is now 200366 was 198420 (+0.98%)
Please check your code again. If you added a new test this can be expected and the base value in tests/integration/base-query-count.txt can be increased.

Place the bottom add-card control outside the scrollable list without overlap-specific spacing or drag handling.

Signed-off-by: Theo <36564257+theoholl@users.noreply.github.com>
Signed-off-by: Theo <36564257+theoholl@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

New cards are created at the bottom of the screen

2 participants