Skip to content

Commit 2148797

Browse files
authored
Move inert attribute to an effect (#1204)
* move inert usage to effect * attempt to trigger canary by simplifying the workflow * add changeset * add todo to component, restore repo check for fork protection
1 parent 4ff667f commit 2148797

File tree

4 files changed

+32
-19
lines changed

4 files changed

+32
-19
lines changed

.changeset/tricky-geese-leave.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@primer/react-brand': patch
3+
---
4+
5+
The `inert` attribute applied to unopened `RiverAccordion` items is now set through a runtime DOM manipulation. This helps to bypass type mismatches between React 18 and 19 but has no material impact to the accessibility or rendering of the final markup.

.github/workflows/release.yml

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ name: Release
22

33
on:
44
push:
5+
# Ignore merge queue branches (matches primer/react configuration)
6+
branches-ignore:
7+
- 'gh-readonly-queue/**'
58
tags-ignore:
69
- '**'
710
workflow_dispatch:
@@ -19,7 +22,7 @@ permissions:
1922

2023
jobs:
2124
release-main:
22-
if: ${{ github.repository == 'primer/brand' && github.ref_name == 'main' }}
25+
if: github.repository == 'primer/brand' && github.ref_name == 'main'
2326
name: Main
2427
runs-on: ubuntu-latest
2528
steps:
@@ -59,7 +62,7 @@ jobs:
5962
GITHUB_TOKEN: ${{ steps.app-token.outputs.token }}
6063

6164
release-next-minor:
62-
if: ${{ github.repository == 'primer/brand' && github.ref_name == 'next-minor' }}
65+
if: github.repository == 'primer/brand' && github.ref_name == 'next-minor'
6366
name: Next minor
6467
runs-on: ubuntu-latest
6568
steps:
@@ -99,7 +102,7 @@ jobs:
99102
GITHUB_TOKEN: ${{ steps.app-token.outputs.token }}
100103

101104
release-candidate:
102-
if: ${{ github.repository == 'primer/brand' && github.ref_name == 'changeset-release/main' }}
105+
if: github.repository == 'primer/brand' && github.ref_name == 'changeset-release/main'
103106
name: Candidate
104107
runs-on: ubuntu-latest
105108
steps:
@@ -145,7 +148,7 @@ jobs:
145148
})
146149
147150
release-candidate-next-minor:
148-
if: ${{ github.repository == 'primer/brand' && github.ref_name == 'changeset-release/next-minor' }}
151+
if: github.repository == 'primer/brand' && github.ref_name == 'changeset-release/next-minor'
149152
name: Next minor candidate (@next-minor)
150153
runs-on: ubuntu-latest
151154
steps:
@@ -197,7 +200,7 @@ jobs:
197200
})
198201
199202
release-canary:
200-
if: ${{ github.repository == 'primer/brand' && github.ref_name != 'main' && github.ref_name != 'next-minor' && !startsWith(github.ref_name, 'changeset-release/') }}
203+
if: github.repository == 'primer/brand' && github.ref_name != 'main' && github.ref_name != 'next-minor' && github.ref_name != 'changeset-release/main' && github.ref_name != 'changeset-release/next-minor'
201204

202205
name: Canary
203206
runs-on: ubuntu-latest

package-lock.json

Lines changed: 7 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/react/src/river/RiverAccordion/RiverAccordion.tsx

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, {createContext, forwardRef, useCallback, useContext, useMemo, useState} from 'react'
1+
import React, {createContext, forwardRef, useCallback, useContext, useMemo, useState, useRef, useEffect} from 'react'
22
import {clsx} from 'clsx'
33
import {PlusIcon} from '@primer/octicons-react'
44

@@ -110,6 +110,16 @@ const RiverAccordionItem = ({className, index, children, ...props}: RiverAccordi
110110
const {openIndex} = useRiverAccordionContext()
111111
const panelId = useId()
112112
const isOpen = index === openIndex
113+
const panelRef = useRef<HTMLDivElement>(null)
114+
115+
useEffect(() => {
116+
if (panelRef.current) {
117+
// Workaround to avoid React 18 / 19 type mismatches with the `inert` attribute.
118+
// This approach won't immediately apply the attribute in pure SSR contexts, only post-hydration
119+
// TODO: Move back to JSX when React 19 is fully adopted in Dotcom.
120+
panelRef.current.toggleAttribute('inert', !isOpen)
121+
}
122+
}, [isOpen])
113123

114124
const itemContextValue = useMemo(
115125
() => ({
@@ -157,12 +167,7 @@ const RiverAccordionItem = ({className, index, children, ...props}: RiverAccordi
157167
{...props}
158168
>
159169
{heading}
160-
<div
161-
className={styles.RiverAccordion__panel}
162-
id={panelId}
163-
aria-hidden={!isOpen}
164-
{...(!isOpen ? ({inert: true} as React.HTMLAttributes<HTMLDivElement>) : undefined)}
165-
>
170+
<div ref={panelRef} className={styles.RiverAccordion__panel} id={panelId} aria-hidden={!isOpen}>
166171
{content}
167172
{visual}
168173
</div>

0 commit comments

Comments
 (0)