forked from microsoft/fluentui
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Panel: onClosed and onOpened fixed in React 18 strict mode (microsoft…
…#26749) * Panel: Fix onOpened callback in React 18 * typing * use internal async, but create new async on each mount * Add events to didMount and remove both from constructor * reset the app file * change file * Update packages/react/src/components/Panel/Panel.base.tsx Co-authored-by: Esteban Munoz Facusse <[email protected]> * remove the button as it has typing issues in r18 context * linting * move functions outside of component * Update change/@fluentui-react-eff13953-3080-4ee9-8ed5-6a778a7f692f.json Co-authored-by: Esteban Munoz Facusse <[email protected]> --------- Co-authored-by: Esteban Munoz Facusse <[email protected]>
- Loading branch information
1 parent
b6fd0db
commit 56f81e3
Showing
3 changed files
with
41 additions
and
7 deletions.
There are no files selected for viewing
27 changes: 27 additions & 0 deletions
27
apps/react-18-tests-v8/src/components/Panel.Basic.Example.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import * as React from 'react'; | ||
import { Panel } from '@fluentui/react/lib/Panel'; | ||
import { useBoolean } from '@fluentui/react-hooks'; | ||
|
||
const handleOpen = () => console.log('onOpen'); | ||
const handleOpened = () => console.log('onOpened'); | ||
|
||
export const PanelBasicExample: React.FunctionComponent = () => { | ||
const [isOpen, { setTrue: openPanel, setFalse: dismissPanel }] = useBoolean(false); | ||
|
||
return ( | ||
<div> | ||
<button onClick={openPanel}> Open panel </button> | ||
<Panel | ||
onOpen={handleOpen} | ||
onOpened={handleOpened} | ||
headerText="Sample panel" | ||
isOpen={isOpen} | ||
onDismiss={dismissPanel} | ||
// You MUST provide this prop! Otherwise screen readers will just say "button" with no label. | ||
closeButtonAriaLabel="Close" | ||
> | ||
<p>Content goes here.</p> | ||
</Panel> | ||
</div> | ||
); | ||
}; |
7 changes: 7 additions & 0 deletions
7
change/@fluentui-react-eff13953-3080-4ee9-8ed5-6a778a7f692f.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"type": "patch", | ||
"comment": "fix: Panel async and events to work in concurrent mode", | ||
"packageName": "@fluentui/react", | ||
"email": "[email protected]", | ||
"dependentChangeType": "patch" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters