[Graph] Enable partial pasting in drilldowns (#96830)

This commit is contained in:
Marco Liberati 2021-04-13 17:15:41 +02:00 committed by GitHub
parent f67f0e80e7
commit 0260dacfc8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -216,15 +216,18 @@ export function UrlTemplateForm(props: UrlTemplateFormProps) {
value={currentTemplate.url}
onChange={(e) => {
setValue('url', e.target.value);
setAutoformatUrl(false);
if (
(e.nativeEvent as InputEvent)?.inputType !== 'insertFromPaste' ||
!isKibanaUrl(e.target.value)
) {
setAutoformatUrl(false);
}
}}
onPaste={(e) => {
e.preventDefault();
const pastedUrl = e.clipboardData.getData('text/plain');
if (isKibanaUrl(pastedUrl)) {
setAutoformatUrl(true);
}
setValue('url', pastedUrl);
}}
isInvalid={urlPlaceholderMissing || (touched.url && !currentTemplate.url)}
/>