fix: do not skip app-wrapper for sibling routes#2911
Conversation
| // By having "bar" come before "foo", this results in a bug | ||
| // where the app wrapper is missing from "foo". | ||
| "routes/bar.tsx": { | ||
| config: { | ||
| skipAppWrapper: true, | ||
| skipInheritedLayouts: true, | ||
| }, | ||
| default: () => <>bar</>, | ||
| }, |
There was a problem hiding this comment.
If route/bar.tsx came after routes/foo.tsx in the record, the issue disappears. Since iteration over the files happens in key-order (for test method createServer) it seems to be some connection to the order FS will walk over the directory for this issue to occur in a real app.
b707f30 to
d48df03
Compare
d48df03 to
c484500
Compare
| if (skipApp && mod.path === "/_app") { | ||
| hasApp = false; | ||
| continue; | ||
| } else if (!skipApp && mod.config?.skipAppWrapper) { | ||
| skipApp = true; | ||
| if (hasApp) { | ||
| hasApp = false; | ||
| // _app component is always first | ||
| components.shift(); |
There was a problem hiding this comment.
I don't know if it's correct just to remove these lines. It looks wrong to me to set hasApp to false if we're looping over every route, since a latter route may have the app wrapper disabled always.
This change makes the test I added pass anyway...
|
@marvinhagemeister I think this PR is ready for review. I don't see any failing tests, and it looks like the test I added now passes so this should likely fix #2910 too. |
marvinhagemeister
left a comment
There was a problem hiding this comment.
Great catch! Seems like always setting hasApp = false was a bit heavy handed. Happy to hear that this was all that's needed to fix it 👍
|
Ah wait kinda wondering if there is a case where a route says to skip the app wrapper, but the next route in the list doesn't. In that case we need to ensure that the app wrapper template is still applied. |
I think that's exactly what I tried to accomplish with my change? To me
It at least looks off to me if Not sure I understood your question. But I don't think I've dug into |
|
Perhaps |
|
Ah you're totally right. I confused |
|
@marvinhagemeister there's been quite a few fixes and changes in the last few weeks. Would it be possible to release a new Alpha version soon? The last release was in January, and it would be nice to test out some of the recent bug-fixes with a new JSR release 🙏 😇 (No pressure though 😁) |
|
@csvn yep, released alpha 30 earlier today. |
This PR adds a unit test for the issue in #2910. I have not found a solution yet, since I'm not very familiar with the
fsRoutescode, and what it is doing. But a thought a unit test with the failing code could help to find a bug fix.Edit: I managed to fix the failing test by removing a couple of lines, but I'm not too familiar with the code so I'm not sure if it's correct. It seems to pass all the tests still...
Closes #2910