I have a Forge App where I pass some HTML with a link to my Custom UI. By using a React.createRef() its possible to put that passed HTML with the link into the table where it gets displayed.
The passed link looks like this:
<a href="#" onClick="router.navigate('LINK_TO_CONFLUENCE_PAGE')">Link</a>
I use router.navigate() as it is described here (https://developer.atlassian.com/platform/forge/custom-ui-bridge/router/) with an import of router in the index.js of my static folder of the Custom UI, therefore I thought the passed link with the onClick-Tag should work there, but it doesn’t.
Did I miss something?
Thats a snipped of my code of the src/index.js that passes the HTML to the Custom UI:
import Resolver from '@forge/resolver';
import { requestConfluence } from '@forge/bridge';
import api, { route } from '@forge/api';
const resolver = new Resolver();
var returnValue = "";
resolver.define('getChildpages', async ({ context }) => {
// REST CALL TO GET CHILDPAGES
for(var i = 0; i < childpages.length; i++) {
// REST CALL, WHERE selfLink GETS CREATED.
returnValue += `<tr><td><a href="#" onClick="router.navigate('` + selfLink + `')">` + title + `</a></td></tr>`;
}
return { returnedTableContent: returnValue };
});
export const handler = resolver.getDefinitions();
And here is my code snipped of the Custom UI index.js in the static/app-name folder:
import React from 'react';
import ReactDOM from 'react-dom';
import '@atlaskit/css-reset';
import { invoke, router } from '@forge/bridge';
class App extends React.Component {
constructor(props) {
super(props);
this.divRef = React.createRef();
}
componentDidMount() {
invoke('getChildpages').then((returnedData) => {
this.divRef.current.innerHTML = returnedData.returnedTableContent;
// SOME INIT STUFF
});
}
render() {
return (
<table id="searchableTable">
<thead>
<tr>
<th>Title</th>
</tr>
</thead>
<tbody ref={this.divRef}>
</tbody>
</table>
);
}
}
ReactDOM.render(
<App />,
document.getElementById('root')
);
The necessary import { router } from '@forge/bridge';
is set there, but when clicking on the link nothing happens.