Skip to content

Commit b5dbe13

Browse files
authored
Merge branch 'main' into slots-layout-effect
2 parents 28a2276 + 4486aa6 commit b5dbe13

File tree

18 files changed

+84
-76
lines changed

18 files changed

+84
-76
lines changed

.changeset/red-wombats-whisper.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@primer/react": patch
3+
---
4+
5+
Replace `useCombinedRefs` with `useRefObjectAsForwardedRef`

.github/workflows/deploy_preview.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,18 @@ permissions:
99

1010
jobs:
1111
deploy-preview:
12-
if: ${{ github.repository == 'primer/react' }}
12+
# if the source repository for pull request is a fork, we don't want to run this workflow,
13+
# we run deploy_preview_forks.yml which uses pull_request_target instead.
14+
# see https://github.com/primer/react/pull/2207 for details
15+
if: ${{ github.event.pull_request.head.repo.full_name == 'primer/react' }} # source repository for pull_request
1316
name: Preview
1417
uses: primer/.github/.github/workflows/deploy_preview.yml@main
1518
permissions:
1619
contents: read
1720
pages: write
1821
id-token: write
22+
secrets:
23+
gh_token: ${{ secrets.GITHUB_TOKEN }}
1924
with:
2025
node_version: 14
2126
install: npm ci && cd docs && npm ci && cd ..
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: Deploy (fork)
2+
on:
3+
pull_request_target:
4+
5+
permissions:
6+
contents: read
7+
pages: write
8+
id-token: write
9+
10+
jobs:
11+
deploy-preview:
12+
if: ${{ github.repository == 'primer/react' }} # target repository for pull_request
13+
name: Preview
14+
uses: primer/.github/.github/workflows/deploy_preview.yml@main
15+
permissions:
16+
contents: read
17+
pages: write
18+
id-token: write
19+
with:
20+
node_version: 14
21+
install: npm ci && cd docs && npm ci && cd ..
22+
build: npm run build:docs:preview
23+
output_dir: docs/public

.github/workflows/deploy_production.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ jobs:
3737
needs: [guard]
3838
if: ${{ needs.guard.outputs.should_deploy == 'true' }}
3939
uses: primer/.github/.github/workflows/deploy.yml@main
40+
secrets:
41+
gh_token: ${{ secrets.GITHUB_TOKEN }}
4042
with:
4143
node_version: 14
4244
install: npm ci && cd docs && npm ci && cd ..

docs/content/ActionMenu.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ import {ActionMenu} from '@primer/react'
7272

7373
### With a custom anchor
7474

75-
You can choose to have a different _anchor_ for the Menu dependending on the application's context.
75+
You can choose to have a different _anchor_ for the Menu depending on the application's context.
7676

7777
 
7878

docs/content/Autocomplete.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@ render(<CustomSortAfterMenuClose />)
314314

315315
#### Custom filtering
316316

317-
In this example, we show any items who's `text` **contains** the input value. By default, we only show items that start with the input value.
317+
In this example, we show any items whose `text` **contains** the input value. By default, we only show items that start with the input value.
318318

319319
```javascript live noinline
320320
const CustomSearchFilter = () => {

docs/content/FormControl.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,7 @@ render(ValidationExample)
350350

351351
### FormControl
352352

353-
The container that handles the layout and passes the relevant IDs and ARIA attributes it's children.
353+
The container that handles the layout and passes the relevant IDs and ARIA attributes its children.
354354

355355
<PropsTable>
356356
<PropsTableRow

docs/content/drafts/Dialog.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import {Dialog} from '@primer/react/drafts'
1010

1111
import State from '../../components/State'
1212

13-
The dialog component the Primer implementation of the ARIA design pattern [Dialog](https://www.w3.org/TR/wai-aria-practices-1.1/#dialog_modal). A dialog is a type of overlay that can be used for confirming actions, asking for disambiguation, and presenting small forms. They generally allow the user to focus on a quick task without having to navigate to a different page.
13+
The dialog component is the Primer implementation of the ARIA design pattern [Dialog](https://www.w3.org/TR/wai-aria-practices-1.1/#dialog_modal). A dialog is a type of overlay that can be used for confirming actions, asking for disambiguation, and presenting small forms. They generally allow the user to focus on a quick task without having to navigate to a different page.
1414

1515
**Dialogs appear in the page after a direct user interaction**. Don't show dialogs on page load or as system alerts.
1616

src/Autocomplete/AutocompleteInput.tsx

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import React, {
22
ChangeEventHandler,
33
FocusEventHandler,
44
KeyboardEventHandler,
5-
MutableRefObject,
65
useCallback,
76
useContext,
87
useEffect,
@@ -11,7 +10,7 @@ import React, {
1110
import {ForwardRefComponent as PolymorphicForwardRefComponent} from '@radix-ui/react-polymorphic'
1211
import {AutocompleteContext} from './AutocompleteContext'
1312
import TextInput from '../TextInput'
14-
import {useCombinedRefs} from '../hooks/useCombinedRefs'
13+
import {useRefObjectAsForwardedRef} from '../hooks/useRefObjectAsForwardedRef'
1514
import {ComponentProps} from '../utils/types'
1615

1716
type InternalAutocompleteInputProps = {
@@ -39,7 +38,7 @@ const AutocompleteInput = React.forwardRef(
3938
setShowMenu,
4039
showMenu
4140
} = autocompleteContext
42-
const combinedInputRef = useCombinedRefs(inputRef, forwardedRef)
41+
useRefObjectAsForwardedRef(forwardedRef, inputRef)
4342
const [highlightRemainingText, setHighlightRemainingText] = useState<boolean>(true)
4443

4544
const handleInputFocus: FocusEventHandler<HTMLInputElement> = useCallback(
@@ -58,12 +57,12 @@ const AutocompleteInput = React.forwardRef(
5857
// this prevents the menu from hiding when the user is clicking an option in the Autoselect.Menu,
5958
// but still hides the menu when the user blurs the input by tabbing out or clicking somewhere else on the page
6059
setTimeout(() => {
61-
if (document.activeElement !== combinedInputRef.current) {
60+
if (document.activeElement !== inputRef.current) {
6261
setShowMenu(false)
6362
}
6463
}, 0)
6564
},
66-
[onBlur, setShowMenu, combinedInputRef]
65+
[onBlur, setShowMenu, inputRef]
6766
)
6867

6968
const handleInputChange: ChangeEventHandler<HTMLInputElement> = useCallback(
@@ -157,7 +156,7 @@ const AutocompleteInput = React.forwardRef(
157156
onKeyDown={handleInputKeyDown}
158157
onKeyPress={onInputKeyPress}
159158
onKeyUp={handleInputKeyUp}
160-
ref={combinedInputRef as MutableRefObject<HTMLInputElement>}
159+
ref={inputRef}
161160
aria-controls={`${id}-listbox`}
162161
aria-autocomplete="both"
163162
role="combobox"

src/Autocomplete/AutocompleteOverlay.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import {useAnchoredPosition} from '../hooks'
33
import Overlay, {OverlayProps} from '../Overlay'
44
import {ComponentProps} from '../utils/types'
55
import {AutocompleteContext} from './AutocompleteContext'
6-
import {useCombinedRefs} from '../hooks/useCombinedRefs'
6+
import {useRefObjectAsForwardedRef} from '../hooks/useRefObjectAsForwardedRef'
77

88
type AutocompleteOverlayInternalProps = {
99
/**
@@ -39,7 +39,7 @@ function AutocompleteOverlay({
3939
[showMenu, selectedItemLength]
4040
)
4141

42-
const combinedOverlayRef = useCombinedRefs(scrollContainerRef, floatingElementRef)
42+
useRefObjectAsForwardedRef(scrollContainerRef, floatingElementRef)
4343

4444
const closeOptionList = useCallback(() => {
4545
setShowMenu(false)
@@ -55,7 +55,7 @@ function AutocompleteOverlay({
5555
preventFocusOnOpen={true}
5656
onClickOutside={closeOptionList}
5757
onEscape={closeOptionList}
58-
ref={combinedOverlayRef as React.RefObject<HTMLDivElement>}
58+
ref={floatingElementRef as React.RefObject<HTMLDivElement>}
5959
top={position?.top}
6060
left={position?.left}
6161
visibility={showMenu ? 'visible' : 'hidden'}

0 commit comments

Comments
 (0)