Reference https://github.com/elastic/kibana/issues/79405.
I have created a trivial visualization plugin with a button. The button works when in the visualization creation/configuration screen. However, once the visualization is added to a dashboard, the button appears to be disabled (no click events are produced). I have had similar results with text inputs EuiButtons and other similar interactive elements. This worked in Kibana 7.7.1, so if this is a bug or there are workarounds that need to be implemented, I'd like to know what those are.
To reproduce in dev mode, create a "another_new_plugin" directory under kibana/plugins, and add the following code to that directory. Create an instance of the visualization. While editing the visualization, if you click the button, a "CLICKED" message will appear in the browser debug window. However, if you save that instance then add it to a dashboard, the button will no longer work in the dashboard.
Code follows:
kibana.json:
{
"id": "anotherNewPlugin",
"version": "kibana",
"ui": true,
"requiredPlugins": ["visualizations"]
}
public/index.ts:
import { PluginInitializerContext } from 'kibana/public';
import { Plugin } from './plugin';
export function plugin(initializerContext: PluginInitializerContext) {
return new Plugin(initializerContext);
}
public/plugin.tsx:
import { PluginInitializerContext, CoreSetup, CoreStart } from 'kibana/public';
import React from 'react';
class MyVisEditor extends React.Component {
render() {
return (
<div>Nothing to configure</div>
);
}
}
const clickFunction = () => {
console.log("CLICKED!");
};
class MyVisComponent extends React.Component {
render() {
return (
<div>A generic panel
<div>Click this button:
<br/>
<br/>
<input type="button" onClick={clickFunction} value="BUTTON"/>
</div>
</div>
);
}
}
const visDefinition = {
name: "my_vis",
title: "My Vis!",
icon: "bullseye",
visConfig: {
component: MyVisComponent
},
editorConfig: {
optionsTemplate: MyVisEditor,
},
requestHandler: "none",
responseHandler: "none",
};
export class Plugin {
constructor(initializerContext: PluginInitializerContext) {
}
public setup(core: CoreSetup, { visualizations }) {
// called when plugin is setting up
visualizations.createReactVisualization(visDefinition);
}
public start(core: CoreStart, { visualizations }) {
}
public stop() {
}
}