react-admin icon indicating copy to clipboard operation
react-admin copied to clipboard

Dynamic window title

Open jtomaszewski opened this issue 4 years ago • 11 comments

Currently all our admin app browser tabs are named in the same way; and the names in the browser history aren't really helpful neither:

image

Maybe we could add some useEffect code to https://github.com/marmelab/react-admin/blob/master/packages/ra-ui-materialui/src/layout/Title.tsx that updates the document.title whenever new title is set? WDYT?

jtomaszewski avatar Feb 10 '21 04:02 jtomaszewski

How I do it with my React Admin:

class SettingsList extends React.Component {
    constructor(props) {
        super(props);
    }

    componentDidMount() {
        document.title = "Some new document title.";
    }

    ......

And it shows that in the history and as the title. But maybe a MaterialUI update version is better.

MicroJackson avatar Feb 11 '21 10:02 MicroJackson

@jtomaszewski Thanks for the suggestion! Would you mind creating a PR for it?

djhi avatar Feb 11 '21 11:02 djhi

Is someone currently working on this? If not, I'd be happy to give it a shot

andrico1234 avatar Apr 02 '21 09:04 andrico1234

@djhi I got carried away 😅

https://github.com/marmelab/react-admin/pull/6118

andrico1234 avatar Apr 02 '21 09:04 andrico1234

Fixed by #6119

fzaninotto avatar May 31 '21 21:05 fzaninotto

@fzaninotto can we re-open this issue as the change was reverted. I'm going to give @wmwart's suggestion,

andrico1234 avatar Jul 05 '21 21:07 andrico1234

Yep, the fix was reverted in #6357, so I'm reopening it.

fzaninotto avatar Jul 06 '21 17:07 fzaninotto

FYI, users can customize browser page title using react-helmet. See example code that can be placed in Show, Edit, List or Create components.

  <Helmet>
      <title>New page title</title>
  </Helmet>

panfiva avatar Feb 01 '22 21:02 panfiva

FYI, users can customize browser page title using react-helmet. See example code that can be placed in Show, Edit, List or Create components.

  <Helmet>
      <title>New page title</title>
  </Helmet>

Ideally, the <Title/> component would automatically sent the title over to Helmet, rather than having users add the title to each page / view.

You can use react portals to inject the title into the

component of react-helmet, but unfortunately, RA adds an additional <span> around the text, which messes up the header title. <p>It would be great if we can override the Title component as part of the customization / layout</p> </span>

btoro avatar Sep 14 '22 14:09 btoro