@@ -2,7 +2,6 @@ import React, { ReactElement, ReactNode } from 'react';
22import Banner from '@veupathdb/coreui/lib/components/banners/Banner' ;
33import { ValidationErrors } from '../../../../Service' ;
44import { BadUpload } from '../../../../StoreModules' ;
5- import { Link } from 'react-router-dom' ;
65
76export interface UploadErrorBannerProps {
87 readonly errors : BadUpload | undefined ;
@@ -52,20 +51,30 @@ function makeValidationErrorMessage(errors: ValidationErrors): ReactElement {
5251
5352 if ( 'byKey' in errors ) {
5453 for ( const jsonPath of Object . keys ( errors . byKey ) ) {
55- const link = document . getElementById ( jsonPath ) ? (
56- < Link to = { `#${ encodeURI ( jsonPath ) } ` } > { formatJPath ( jsonPath ) } </ Link >
57- ) : (
58- formatJPath ( jsonPath )
59- ) ;
54+ // using `<a href` instead of `<Link` as Link does not properly handle
55+ // standard hash/anchor links. For that the library
56+ // `react-router-hash-link` is needed, however in this situation, we are
57+ // not changing the view in any way, so a normal HTML anchor link works
58+ // fine.
59+ const element = document . getElementById ( jsonPath ) ;
60+
61+ const link = element == null
62+ ? formatJPath ( jsonPath )
63+ : (
64+ < button
65+ className = "error-link"
66+ type = "button"
67+ onClick = { ( ) => {
68+ element . scrollIntoView ( ) ;
69+ element . focus ( ) ;
70+ } }
71+ >
72+ { formatJPath ( jsonPath ) }
73+ </ button >
74+ ) ;
6075
6176 for ( const msg of errors . byKey [ jsonPath ] ) {
62- elements . push (
63- newLI (
64- < >
65- { link } : { msg }
66- </ >
67- )
68- ) ;
77+ elements . push ( newLI ( < > { link } : { msg } </ > ) ) ;
6978 }
7079 }
7180 }
0 commit comments