diff --git a/.github/ISSUE_TEMPLATE/BUG_REPORT.md b/.github/ISSUE_TEMPLATE/BUG_REPORT.md index f82aab2335..448031e628 100644 --- a/.github/ISSUE_TEMPLATE/BUG_REPORT.md +++ b/.github/ISSUE_TEMPLATE/BUG_REPORT.md @@ -8,20 +8,21 @@ labels: 'possible-bug' -## Expected Behavior - - - ## Current Behavior +## Expected Behavior + + + ## Possible Solution - + ## Steps to Reproduce + 1. 2. 3. diff --git a/CHANGELOG.md b/CHANGELOG.md index c50b7bde4b..1fd757f106 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,10 @@ +## [1.1.5](https://github.com/payloadcms/payload/compare/v1.1.4...v1.1.5) (2022-09-29) + + +### Bug Fixes + +* bug in useThrottledEffect ([3ce8ee4](https://github.com/payloadcms/payload/commit/3ce8ee4661bfa3825c5b8c41232d5da57f7591ed)) + ## [1.1.4](https://github.com/payloadcms/payload/compare/v1.1.3...v1.1.4) (2022-09-24) diff --git a/package.json b/package.json index 90a655c022..09af573914 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "payload", - "version": "1.1.4", + "version": "1.1.5", "description": "Node, React and MongoDB Headless CMS and Application Framework", "license": "MIT", "author": { diff --git a/src/admin/hooks/useThrottledEffect.tsx b/src/admin/hooks/useThrottledEffect.tsx index 362112870a..79d1125b7e 100644 --- a/src/admin/hooks/useThrottledEffect.tsx +++ b/src/admin/hooks/useThrottledEffect.tsx @@ -4,10 +4,10 @@ import { useEffect, useRef } from 'react'; type useThrottledEffect = (callback: React.EffectCallback, delay: number, deps: React.DependencyList) => void; const useThrottledEffect: useThrottledEffect = (callback, delay, deps = []) => { - const lastRan = useRef(null); + const lastRan = useRef(Date.now()); - useEffect(() => { - if (lastRan) { + useEffect( + () => { const handler = setTimeout(() => { if (Date.now() - lastRan.current >= delay) { callback(); @@ -18,12 +18,9 @@ const useThrottledEffect: useThrottledEffect = (callback, delay, deps = []) => { return () => { clearTimeout(handler); }; - } - - callback(); - lastRan.current = Date.now(); - return () => null; - }, [delay, ...deps]); + }, + [delay, ...deps], + ); }; export default useThrottledEffect; diff --git a/src/express/middleware/corsHeaders.ts b/src/express/middleware/corsHeaders.ts index 5e68eadd01..ca1fdc1289 100644 --- a/src/express/middleware/corsHeaders.ts +++ b/src/express/middleware/corsHeaders.ts @@ -5,7 +5,7 @@ export default (config: SanitizedConfig) => ( (req: Request, res: Response, next: NextFunction) => { if (config.cors) { res.header('Access-Control-Allow-Methods', 'PUT, PATCH, POST, GET, DELETE, OPTIONS'); - res.header('Access-Control-Allow-Headers', 'Origin, X-Requested-With, Content-Type, Accept, Authorization, Content-Encoding'); + res.header('Access-Control-Allow-Headers', 'Origin, X-Requested-With, Content-Type, Accept, Authorization, Content-Encoding, x-apollo-tracing'); if (config.cors === '*') { res.setHeader('Access-Control-Allow-Origin', '*'); diff --git a/src/init.ts b/src/init.ts index 2a3dd916fb..fbb4d299d1 100644 --- a/src/init.ts +++ b/src/init.ts @@ -100,6 +100,13 @@ export const init = (payload: Payload, options: InitOptions): void => { if (!payload.config.graphQL.disable) { payload.router.use( payload.config.routes.graphQL, + (req, res, next): void => { + if (req.method === 'OPTIONS') { + res.sendStatus(204); + } else { + next(); + } + }, identifyAPI('GraphQL'), (req: PayloadRequest, res: Response) => graphQLHandler(req, res)(req, res), ); diff --git a/test/fields/e2e.spec.ts b/test/fields/e2e.spec.ts index 0cc7865d9b..2d8c36f7dd 100644 --- a/test/fields/e2e.spec.ts +++ b/test/fields/e2e.spec.ts @@ -102,7 +102,7 @@ describe('fields', () => { await page.locator('#field-textInRow').fill(textInRowValue); await page.locator('#field-numberInRow').fill(numberInRowValue); - await wait(100); + await wait(300); await page.locator('.tabs-field__tab-button:has-text("Tab with Array")').click(); await page.locator('.tabs-field__tab-button:has-text("Tab with Row")').click(); @@ -134,7 +134,7 @@ describe('fields', () => { await page.locator('.tabs-field__tab-button:has-text("Tab with Array")').click(); await page.click('#action-save', { delay: 100 }); - await wait(100); + await wait(250); // Go back to row tab, make sure the new value is still present await page.locator('.tabs-field__tab-button:has-text("Tab with Row")').click();