Skip to content

Commit

Permalink
Fix Attributes view not refreshed immediately for a plugin
Browse files Browse the repository at this point in the history
Applied workaround that explicitly navigates to the same path so that
the Attributes view rendering is triggered forcibly.

Ideally, the issue should be fixed at @hawtio/react.
  • Loading branch information
tadayosi committed Mar 23, 2024
1 parent 717c0ec commit c10571d
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions sample-plugin/src/sample-plugin/app-jmx/AppJmx.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ import {
} from '@patternfly/react-core'
import { CubesIcon } from '@patternfly/react-icons'
import React, { useContext } from 'react'
import { NavLink, Navigate, Route, Routes, useLocation } from 'react-router-dom'
import { NavLink, Navigate, Route, Routes, useLocation, useNavigate } from 'react-router-dom'
import Split from 'react-split'
import './AppJmx.css'
import { AppJmxContext, useAppJmx } from './context'
import { pluginPath } from './globals'
import { log, pluginPath } from './globals'

export const AppJmx: React.FunctionComponent = () => {
const { tree, loaded, selectedNode, setSelectedNode } = useAppJmx()
Expand Down Expand Up @@ -51,9 +51,13 @@ export const AppJmx: React.FunctionComponent = () => {

const AppJmxTreeView: React.FunctionComponent = () => {
const { tree, selectedNode, setSelectedNode } = useContext(AppJmxContext)
const navigate = useNavigate()

const onSelect: TreeViewProps['onSelect'] = (_, item) => {
log.debug('Selected node:', item)
setSelectedNode(item as MBeanNode)
// TODO: Workaround for the issue that otherwise the attributes are not updated immediately
navigate(pluginPath)
}

return (
Expand Down

0 comments on commit c10571d

Please sign in to comment.