Category selectors shouldn't be updated when selecting and failing to set a parent category

AI-generated summary

The discussion addresses a bug where category selectors are incorrectly updated when attempting to set a parent category that fails due to an error, such as a category already having a child. This leads to navigation issues, including a 404 error when returning to the category edit page, which only resolves after a page refresh. Canapin reports the issue with a video demonstrating the problem. sam agrees it should be fixed and marks it as a pr-welcome issue. DukeManh volunteers to fix it, seeking guidance on testing. sam encourages the effort, and jancernik later adds a test and merges the pull request Fix: Handle failing to update parent category by DukeManh · Pull Request #24401 · discourse/discourse (github.com).

In my example, I’m trying to set a parent category on a category that already has a child category. Naturally, I hit an error message. Despite this, the category selectors are updated as if my action was successful.
Navigating back to the topic list (through the previous button from my browser) and back to the category edition leads to a 404.

These navigation issues persist until I force a page refresh.

The interface shouldn’t be updated in real-time to reflect a change if that change didn’t work. :slight_smile:

4 Likes

Agree we should fix, putting a pr-welcome on this for now.

Hi @sam, I’d like to fix this.
I’m learning Rails and figure this word be a good issue to dive into a Rails code base.

Btw, I’m interested on the backend side of Rails, let me know if you know any bug I can help with:). Thanks!

Sure, feel free to give it a shot!

@sam could you review Fix: Handle failing to update parent category by DukeManh · Pull Request #24401 · discourse/discourse (github.com) please?

Do you think it needs test? If yes could you refer me to a file that does testing?

Ideally it needs a test, but even as is it is helpful … thanks @DukeManh

1 Like

I added a test and went ahead and merged it. Thanks, @DukeManh, for the contribution!

https://github.com/discourse/discourse/pull/24401#pullrequestreview-1750578047

3 Likes

This topic was automatically closed after 20 hours. New replies are no longer allowed.