1+ import { useEffect , useRef } from 'react' ;
12import { t } from '../i18n/strings.js' ;
23import {
34 localized ,
@@ -7,10 +8,26 @@ import {
78} from '../data/grip.js' ;
89import LicenseBadge from './LicenseBadge.jsx' ;
910
11+ // Breakpoint at which the layout switches to a single column (matches CSS).
12+ const MOBILE_BREAKPOINT = 1080 ;
13+
1014export default function MeasureDetailPanel ( { measure, lang, onClose } ) {
15+ const panelRef = useRef ( null ) ;
16+
17+ useEffect ( ( ) => {
18+ if (
19+ measure &&
20+ panelRef . current &&
21+ typeof panelRef . current . scrollIntoView === 'function' &&
22+ window . innerWidth <= MOBILE_BREAKPOINT
23+ ) {
24+ panelRef . current . scrollIntoView ( { behavior : 'smooth' , block : 'start' } ) ;
25+ }
26+ } , [ measure ] ) ;
27+
1128 if ( ! measure ) {
1229 return (
13- < aside className = "detail detail--empty" aria-live = "polite" >
30+ < aside ref = { panelRef } className = "detail detail--empty" aria-live = "polite" >
1431 < h2 className = "detail__empty-title" > { t ( lang , 'selectMeasure' ) } </ h2 >
1532 < p className = "detail__empty-hint" > { t ( lang , 'selectMeasureHint' ) } </ p >
1633 </ aside >
@@ -26,7 +43,7 @@ export default function MeasureDetailPanel({ measure, lang, onClose }) {
2643 measure . type === 'T' ? t ( lang , 'technical' ) : t ( lang , 'organisational' ) ;
2744
2845 return (
29- < aside className = "detail" aria-live = "polite" >
46+ < aside ref = { panelRef } className = "detail" aria-live = "polite" >
3047 < header className = "detail__head" >
3148 < div className = "detail__head-meta" >
3249 < span className = "detail__code" > { measure . code } </ span >
0 commit comments