-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(react-drawer): apply position: absolute when mountNode is passed (#…
- Loading branch information
1 parent
db57a7b
commit bcefcd0
Showing
7 changed files
with
99 additions
and
4 deletions.
There are no files selected for viewing
7 changes: 7 additions & 0 deletions
7
change/@fluentui-react-drawer-6eaa1e97-38f8-4d08-8748-8eecd859a585.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: apply position: absolute when mountNode is passed", | ||
"packageName": "@fluentui/react-drawer", | ||
"email": "marcosvmmoura@gmail.com", | ||
"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
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
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
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
79 changes: 79 additions & 0 deletions
79
packages/react-components/react-drawer/stories/src/Drawer/OverlayInsideContainer.stories.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,79 @@ | ||
import * as React from 'react'; | ||
import { | ||
DrawerBody, | ||
DrawerHeader, | ||
DrawerHeaderTitle, | ||
OverlayDrawer, | ||
Button, | ||
makeStyles, | ||
tokens, | ||
} from '@fluentui/react-components'; | ||
import { Dismiss24Regular } from '@fluentui/react-icons'; | ||
|
||
const useStyles = makeStyles({ | ||
root: { | ||
display: 'flex', | ||
alignItems: 'flex-start', | ||
gap: tokens.spacingHorizontalL, | ||
}, | ||
|
||
container: { | ||
width: '500px', | ||
height: '300px', | ||
padding: `${tokens.spacingVerticalL} ${tokens.spacingHorizontalL}`, | ||
position: 'relative', | ||
overflow: 'hidden', | ||
border: `${tokens.strokeWidthThicker} solid ${tokens.colorNeutralStroke1}`, | ||
backgroundColor: tokens.colorBrandBackground2, | ||
}, | ||
}); | ||
|
||
export const OverlayInsideContainer = () => { | ||
const [isOpen, setIsOpen] = React.useState(false); | ||
const ref = React.useRef<HTMLDivElement>(null); | ||
const styles = useStyles(); | ||
|
||
return ( | ||
<div className={styles.root}> | ||
<div className={styles.container} ref={ref}> | ||
<OverlayDrawer as="aside" mountNode={ref.current} open={isOpen} onOpenChange={(_, { open }) => setIsOpen(open)}> | ||
<DrawerHeader> | ||
<DrawerHeaderTitle | ||
action={ | ||
<Button | ||
appearance="subtle" | ||
aria-label="Close" | ||
icon={<Dismiss24Regular />} | ||
onClick={() => setIsOpen(false)} | ||
/> | ||
} | ||
> | ||
Overlay Drawer | ||
</DrawerHeaderTitle> | ||
</DrawerHeader> | ||
|
||
<DrawerBody> | ||
<p>Drawer content</p> | ||
</DrawerBody> | ||
</OverlayDrawer> | ||
|
||
<p>Drawer will be rendered within this container</p> | ||
</div> | ||
|
||
<Button appearance="primary" onClick={() => setIsOpen(true)}> | ||
Open Drawer | ||
</Button> | ||
</div> | ||
); | ||
}; | ||
|
||
OverlayInsideContainer.parameters = { | ||
docs: { | ||
description: { | ||
story: [ | ||
'The overlay Drawer can be rendered inside a specific container by setting the `mountNode` prop to the desired container element.', | ||
'This approach is useful when you need the Drawer to appear within a particular section of the DOM, rather than being attached to the root element.', | ||
].join('\n'), | ||
}, | ||
}, | ||
}; |
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