From 4583daa1bfd4d6c1aebb8976cd43b31eb500b082 Mon Sep 17 00:00:00 2001 From: pyphilia Date: Mon, 29 Nov 2021 17:45:05 +0100 Subject: [PATCH] ci: add test workflow --- .github/workflows/test.yml | 29 +++++++++++++++++++++++++++++ src/items/FilePdf.tsx | 8 +++++--- 2 files changed, 34 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/test.yml diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 000000000..b61973a7b --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,29 @@ +name: Node CI + +on: [push] + +jobs: + build-node: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + - name: Use Node.js 16.x + uses: actions/setup-node@v1 + with: + node-version: 16.x + - name: Get npm cache directory + id: npm-cache + run: | + echo "::set-output name=dir::$(npm config get cache)" + - uses: actions/cache@v2 + with: + path: ${{ steps.npm-cache.outputs.dir }} + key: ${{ runner.os }}-node-${{ hashFiles('**/yarn.lock') }} + restore-keys: | + ${{ runner.os }}-node- + - name: yarn install, build, and test + run: | + yarn + yarn build + # yarn test diff --git a/src/items/FilePdf.tsx b/src/items/FilePdf.tsx index ea453d8d3..12f3119a9 100644 --- a/src/items/FilePdf.tsx +++ b/src/items/FilePdf.tsx @@ -1,4 +1,4 @@ -import React, { FC, useRef, useState } from 'react'; +import React, { FC, useRef, useState, ReactEventHandler } from 'react'; import { makeStyles } from '@material-ui/core/styles'; import { ITEM_MAX_HEIGHT } from '../constants'; @@ -21,9 +21,11 @@ const FilePdf: FC = ({ url, id, height: defaultHeight }) => { defaultHeight ?? '100%', ); - const onLoad = (e): void => { + const onLoad: ReactEventHandler = (e) => { // set pdf height -> probably very high - setHeight(e.target?.offsetParent?.scrollHeight); + const newHeight = (e.target as HTMLEmbedElement)?.offsetParent + ?.scrollHeight; + newHeight && setHeight(newHeight); }; return (