Closed mshabarov closed 3 months ago
Cannot reproduce here, the title shows up correctly:
When looking though the bundled JS, the page title is preserved with explicit Object.defineProperty()
:
Apparently I had this issue because of some old JS files for TSX views. After remove and rebuild the issue is gone.
@mshabarov
I have the same issue, can you specifiy, where these old JS files where located? And have you deleted them manually? Since that seems to be reproducible somehow, the deletion of these old js files on production build should maybe be automated?
It seems that the usage of the useViewConfig() hook is broken in production mode, when the view has no title configured via view config.
@platosha
Here is a way to reproduce it 🙂
Broken Title:
import {useEffect} from 'react';
import {useViewConfig} from "@vaadin/hilla-file-router/runtime.js";
export default function NoConfigView() {
const currentTitle = useViewConfig()?.title ?? 'My App';
useEffect(() => {
document.title = currentTitle;
}, [currentTitle]);
return (
<span>this has no config</span>
);
}
Working Title:
import {ViewConfig} from '@vaadin/hilla-file-router/types.js';
import {useViewConfig} from "@vaadin/hilla-file-router/runtime.js";
import {useEffect} from "react";
export const config: ViewConfig = {
title: 'A specific title'
};
export default function ConfigViewView() {
const currentTitle = useViewConfig()?.title ?? 'My App';
useEffect(() => {
document.title = currentTitle;
}, [currentTitle]);
return (
<span>this has a config</span>
);
}
Therefore this issue should be reopened.
Workaround Define view titles using the view config
Description of the bug
Page titles for Hilla views are shown incorrectly, e.g. "C T" instead of "Public page", see attached screenshot:
Prod mode
Dev mode
and that happens in production mode only.
Looks similar to https://github.com/vaadin/hilla/issues/2318.
Flow titles are shown correctly.
Expected behavior
Titles are shown as they defined with ViewConfig.
Minimal reproducible example
Checkout https://github.com/vaadin/flow-hilla-hybrid-example/pull/47 and run
mvn spring-boot:run -Pproduction
, then open localhost:8080, login with user/user, navigate to any Hilla view.Versions