Since the Panel runs mostly in the frontend, you can’t redirect from the backend. Hooks are only made to be passive and do stuff in the background, but can’t control the user flow in the Panel at this point.
I used “window.location.replace()” for redirecting, don’t know if this is the best practice. I tried to use the “PagesController.show” function, but it didn’t work.
Why am I doing this?
From a UX point of view, I don’t get the idea of a new page being added but not opened afterwards for further editing of the contents. I think everyone adding a page in the panel wants to edit it immediately, and since there is no such thing like a batch mode for creating many pages at once, I don’t see why this should be the default workflow when adding pages. If there is a reason for that, please tell me.
I think that discussion has cropped up before, can’t find the link right now. While there are certainly use cases where it might make sense to just create the page instead of editing it at once, I see your point. In fact, it would probably be even better if page creation and editing were one step, i.e. as soon as you click the add button, you are redirected to the page creation form, instead of first filling in a modal form with the title and then being redirected.
I think this issue might already have been added as feature request on Github, if not, you might like to create a new one?
I found this issue. Here, the request is to provide a “Create & Edit” button within the “Add page”-modal, in addition to the “Create” and “Cancel” buttons. @bastianallgeier already accepted this as a good idea, but as @texnixe said, using this approach, two steps have to be done for creating the new page:
Click on"Add page" and modal pops up.
Click on “Create & Edit” buttons and the editing interface for the new page opens.
whereas a unique button/step for page creation and editing, all at once, would be even better.
I’ll add a comment regarding this into the issue on GitHub.