-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(Drawer): ensure ScrollView is used for scrollable content
- Loading branch information
1 parent
7ed9550
commit ff62ebe
Showing
31 changed files
with
216 additions
and
247 deletions.
There are no files selected for viewing
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
68 changes: 68 additions & 0 deletions
68
packages/dnb-design-system-portal/src/docs/uilib/components/drawer/visual-tests/Examples.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,68 @@ | ||
/** | ||
* UI lib Component Example | ||
* | ||
*/ | ||
|
||
import React from 'react' | ||
import ComponentBox from 'dnb-design-system-portal/src/shared/tags/ComponentBox' | ||
|
||
export const DrawerScrollViewSetup = () => ( | ||
<ComponentBox useRender data-visual-test="drawer-scroll-view"> | ||
{ | ||
/* jsx */ ` | ||
const DrawerMock = () => { | ||
const scrollRef = React.useRef() | ||
const innerRef = React.useRef() | ||
const [errorMessage, setErrorMessage] = React.useState(null) | ||
const message = errorMessage | ||
? errorMessage | ||
: 'Yes, the "dnb-scroll-view" is used!' | ||
return ( | ||
<Drawer | ||
contentRef={innerRef} | ||
scrollRef={scrollRef} | ||
onOpen={() => { | ||
const innerOverflowY = window.getComputedStyle( | ||
innerRef.current | ||
).overflowY | ||
const contentElem = scrollRef.current.querySelector( | ||
'.dnb-drawer__content' | ||
) | ||
const contentOverflowY = | ||
window.getComputedStyle(contentElem)?.overflowY | ||
const scxrollOverflowY = window.getComputedStyle( | ||
scrollRef.current | ||
).overflowY | ||
if (contentOverflowY !== 'visible') { | ||
setErrorMessage( | ||
'.dnb-drawer__content was "'+contentOverflowY+'" and not "visible"' | ||
) | ||
} else if (innerOverflowY !== 'visible') { | ||
setErrorMessage( | ||
'.dnb-drawer__inner was "'+innerOverflowY+'" and not "visible"' | ||
) | ||
} else if (scxrollOverflowY !== 'auto') { | ||
setErrorMessage('.dnb-scroll-view was not "auto"') | ||
} | ||
}} | ||
> | ||
<Drawer.Body> | ||
<div style={{ height: '100rem' }}> | ||
<div className="drawer-scroll-view"> | ||
<P size="x-large">{message}</P> | ||
</div> | ||
</div> | ||
</Drawer.Body> | ||
</Drawer> | ||
) | ||
} | ||
render(<DrawerMock />) | ||
` | ||
} | ||
</ComponentBox> | ||
) |
9 changes: 9 additions & 0 deletions
9
...ign-system-portal/src/docs/uilib/components/drawer/visual-tests/hidden-tests.md
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,9 @@ | ||
--- | ||
draft: true | ||
--- | ||
|
||
import { | ||
DrawerScrollViewSetup, | ||
} from 'Docs/uilib/components/drawer/visual-tests/Examples' | ||
|
||
<DrawerScrollViewSetup /> |
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
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
Oops, something went wrong.