Skip to content

Commit

Permalink
Fix collapse div height if font changes
Browse files Browse the repository at this point in the history
* Remove unused fontSize

* Allow forbidden non-null assertion

* Use policies div to calculate collapse div
  • Loading branch information
Klukies authored Mar 16, 2021
1 parent c03bcc2 commit 9e8327e
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 6 deletions.
1 change: 1 addition & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ module.exports = {
files: ['*.js', '*.ts', '*.tsx', '*.d.ts'],
rules: {
'@typescript-eslint/explicit-module-boundary-types': 'off',
'@typescript-eslint/no-non-null-assertion': 'off',
},
},
],
Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)

- Nothing yet!

## [1.1.3] - 2021-03-16

### Fixed

- Fix height of the collapse div in case it changes

## [1.1.2] - 2021-03-10

### Fixed
Expand Down
2 changes: 1 addition & 1 deletion src/components/customization/collapse.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const Collapse: FunctionalComponent<Props> = ({ isOpen, children, onWindowResize
const expand = useCallback((isResize = false) => {
const { collapsedHeight, containerOffset } = getContainerHeights();
const windowHeight = window.innerHeight;
const collapseHeight = collapsibleDiv.current.scrollHeight;
const collapseHeight = collapsibleDiv.current.querySelector('.ct-policies')!.scrollHeight;

if (isResize) {
collapsibleDiv.current.style.transition = 'height 0ms ease-out';
Expand Down
2 changes: 1 addition & 1 deletion src/components/customization/options.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const Options: FunctionalComponent<Props> = ({
));

return (
<div>
<div className="ct-policies">
{cookies}
{cookiePolicy && (
<div className="ct-declaration">
Expand Down
1 change: 1 addition & 0 deletions src/tests/app.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ describe('Cookie Though', () => {

describe('if the user has a different browser font setting', () => {
const renderApp = (fontSize: string) => {
container.style.fontSize = fontSize;
return mount(
<App
customizeLabel="customize"
Expand Down
8 changes: 4 additions & 4 deletions src/tests/components/customization/collapse.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ describe('collapse', () => {
const wrapper = mount(
<div className="visible">
<Collapse isOpen={true} onWindowResize={onWindowResize}>
<p></p>
<div className="ct-policies"></div>
</Collapse>
<div class="ct-acceptance"></div>
</div>,
Expand All @@ -49,7 +49,7 @@ describe('collapse', () => {
const wrapper = mount(
<div className="visible">
<Collapse isOpen={true} onWindowResize={onWindowResize}>
<p></p>
<div className="ct-policies"></div>
</Collapse>
<div class="ct-acceptance"></div>
</div>,
Expand All @@ -67,7 +67,7 @@ describe('collapse', () => {
const wrapper = mount(
<div className="visible">
<Collapse isOpen={true} onWindowResize={onWindowResize}>
<p></p>
<div className="ct-policies"></div>
</Collapse>
</div>,
);
Expand All @@ -87,7 +87,7 @@ describe('collapse', () => {
const wrapper = mount(
<div className="visible">
<Collapse isOpen={true} onWindowResize={onWindowResize}>
<p></p>
<div className="ct-policies"></div>
</Collapse>
</div>,
);
Expand Down

0 comments on commit 9e8327e

Please sign in to comment.