Skip to content

Commit

Permalink
update title when jump from view to folder (#6886)
Browse files Browse the repository at this point in the history
* update title when jump from view to folder

* reset title when leave view page

* remove warnings

---------

Co-authored-by: zhouwenxuan <[email protected]>
Co-authored-by: Michael An <[email protected]>
  • Loading branch information
3 people authored Oct 14, 2024
1 parent 52cccb5 commit 600c608
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
10 changes: 9 additions & 1 deletion frontend/src/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import ReactDom from 'react-dom';
import { Router, navigate } from '@gatsbyjs/reach-router';
import MediaQuery from 'react-responsive';
import { Modal } from 'reactstrap';
import { siteRoot } from './utils/constants';
import { siteRoot, siteTitle, mediaUrl, faviconPath } from './utils/constants';
import { Utils, isMobile } from './utils/utils';
import SystemNotification from './components/system-notification';
import EventBus from './components/common/event-bus';
Expand Down Expand Up @@ -105,6 +105,12 @@ class App extends Component {
this.setState({ currentTab: currentTab });
}

resetTitle = () => {
const favicon = document.getElementById('favicon');
favicon.href = `${mediaUrl}${faviconPath}`;
document.title = siteTitle;
};

onCloseSidePanel = () => {
this.setState({
isSidePanelClosed: !this.state.isSidePanelClosed
Expand Down Expand Up @@ -162,6 +168,7 @@ class App extends Component {
if (!Utils.isDesktop() && !this.state.isSidePanelClosed) {
this.setState({ isSidePanelClosed: true });
}
this.resetTitle();
};

generatorPrefix = (tabName, groupID) => {
Expand Down Expand Up @@ -337,6 +344,7 @@ class App extends Component {
isSidePanelFolded={isSidePanelFolded}
onTabNavClick={this.tabItemClick}
eventBus={this.eventBus}
resetTitle={this.resetTitle}
/>
</Router>
</div>
Expand Down
3 changes: 2 additions & 1 deletion frontend/src/pages/lib-content-view/lib-content-view.js
Original file line number Diff line number Diff line change
Expand Up @@ -452,6 +452,7 @@ class LibContentView extends React.Component {

showDir = (path) => {
let repoID = this.props.repoID;
this.props.resetTitle();

if (!this.state.isSessionExpired) {
// update state
Expand Down Expand Up @@ -2439,7 +2440,7 @@ class LibContentView extends React.Component {
/>
)}
<MediaQuery query="(max-width: 767.8px)">
<Modal zIndex="1030" isOpen={!Utils.isDesktop() && this.state.isTreePanelShown} toggle={this.toggleTreePanel} contentClassName="d-none"></Modal>
<Modal zIndex="1030" isOpen={!isDesktop && this.state.isTreePanelShown} toggle={this.toggleTreePanel} contentClassName="d-none"></Modal>
</MediaQuery>
</CollaboratorsProvider>
</MetadataProvider>
Expand Down

0 comments on commit 600c608

Please sign in to comment.