From 7d715d6becc4d6a1379be224be58cd5f65ca6044 Mon Sep 17 00:00:00 2001 From: SSSS Date: Tue, 13 Aug 2024 13:33:01 +0800 Subject: [PATCH 1/4] fix: cannot select end time in shadow dom (#860) --- src/PickerInput/RangePicker.tsx | 7 ++++++- tests/range.spec.tsx | 29 +++++++++++++++++++++++++++++ tests/util/commonUtil.tsx | 14 ++++++-------- 3 files changed, 41 insertions(+), 9 deletions(-) diff --git a/src/PickerInput/RangePicker.tsx b/src/PickerInput/RangePicker.tsx index 816a8114a..46a0ced79 100644 --- a/src/PickerInput/RangePicker.tsx +++ b/src/PickerInput/RangePicker.tsx @@ -428,7 +428,12 @@ function RangePicker( // ======================== Click ========================= const onSelectorClick: React.MouseEventHandler = (event) => { - if (!selectorRef.current.nativeElement.contains(document.activeElement)) { + const rootNode = (event.target as HTMLElement).getRootNode(); + if ( + !selectorRef.current.nativeElement.contains( + (rootNode as Document | ShadowRoot).activeElement ?? document.activeElement, + ) + ) { // Click to focus the enabled input const enabledIndex = disabled.findIndex((d) => !d); if (enabledIndex >= 0) { diff --git a/tests/range.spec.tsx b/tests/range.spec.tsx index 3b39edf5e..9647bee90 100644 --- a/tests/range.spec.tsx +++ b/tests/range.spec.tsx @@ -1,6 +1,7 @@ // Note: zombieJ refactoring import { act, createEvent, fireEvent, render } from '@testing-library/react'; +import { createRoot } from 'react-dom/client'; import type { Dayjs } from 'dayjs'; import dayjs from 'dayjs'; import KeyCode from 'rc-util/lib/KeyCode'; @@ -1973,4 +1974,32 @@ describe('Picker.Range', () => { ]); expect(isOpen()).toBeFalsy(); }); + + const renderShadow = (props?: any) => { + const host = document.createElement('div'); + document.body.appendChild(host); + + const shadowRoot = host.attachShadow({ + mode: 'open', + delegatesFocus: false, + }); + const container = document.createElement('div'); + shadowRoot.appendChild(container); + + act(() => { + createRoot(container).render(); + }); + + return shadowRoot; + }; + + it('the end date selector can be selected in shadow dom', () => { + const shadowRoot = renderShadow(); + + openPicker(shadowRoot, 1); + + expect(shadowRoot.querySelectorAll('.rc-picker-input')[1]).toHaveClass( + 'rc-picker-input-active', + ); + }); }); diff --git a/tests/util/commonUtil.tsx b/tests/util/commonUtil.tsx index ac5559517..cc972e330 100644 --- a/tests/util/commonUtil.tsx +++ b/tests/util/commonUtil.tsx @@ -112,7 +112,7 @@ export async function waitFakeTimer() { }); } -export function openPicker(container: HTMLElement, index = 0) { +export function openPicker(container: HTMLElement | ShadowRoot, index = 0) { const input = container.querySelectorAll('input')[index]; fireEvent.mouseDown(input); @@ -123,7 +123,7 @@ export function openPicker(container: HTMLElement, index = 0) { fireEvent.click(input); } -export function closePicker(container: HTMLElement, index = 0) { +export function closePicker(container: HTMLElement | ShadowRoot, index = 0) { const input = container.querySelectorAll('input')[index]; fireEvent.blur(input); @@ -236,11 +236,9 @@ const dateFnsLocale = { generateConfig: dateFnsGenerateConfig, }; -type DateFnsSinglePickerProps = Omit, 'locale' | 'generateConfig'> & React.RefAttributes; +type DateFnsSinglePickerProps = Omit, 'locale' | 'generateConfig'> & + React.RefAttributes; export const DateFnsSinglePicker = (props: DateFnsSinglePickerProps) => { - return -} \ No newline at end of file + return ; +}; From bc7bf6343e6a83a780a23ebe4517acd750c8747b Mon Sep 17 00:00:00 2001 From: afc163 Date: Tue, 13 Aug 2024 13:37:44 +0800 Subject: [PATCH 2/4] 4.6.13 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 615fad717..5f7128fbe 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "rc-picker", - "version": "4.6.12", + "version": "4.6.13", "description": "React date & time picker", "keywords": [ "react", From a368aa5070de44aacdb3f20af95b5f63e83f7fc1 Mon Sep 17 00:00:00 2001 From: Avan Date: Tue, 13 Aug 2024 18:09:44 +0800 Subject: [PATCH 3/4] test: use codecov/codecov-action (#861) --- .github/workflows/main.yml | 46 ++++++++++++++++++++------------------ 1 file changed, 24 insertions(+), 22 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 7e33cc47b..2097f2a72 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -1,30 +1,26 @@ name: CI -on: - push: - branches: [master] - pull_request: - branches: [master] +on: ['push', 'pull_request'] jobs: setup: runs-on: ubuntu-latest steps: - name: checkout - uses: actions/checkout@master + uses: actions/checkout@v4 - - uses: actions/setup-node@v1 + - uses: actions/setup-node@v4 with: - node-version: '16' + node-version: '20' - name: cache package-lock.json - uses: actions/cache@v2 + uses: actions/cache@v4 with: path: package-temp-dir key: lock-${{ github.sha }} - name: create package-lock.json - run: npm i --package-lock-only + run: npm i --package-lock-only --ignore-scripts - name: hack for singe file run: | @@ -32,9 +28,10 @@ jobs: mkdir package-temp-dir fi cp package-lock.json package-temp-dir + - name: cache node_modules id: node_modules_cache_id - uses: actions/cache@v2 + uses: actions/cache@v4 with: path: node_modules key: node_modules-${{ hashFiles('**/package-temp-dir/package-lock.json') }} @@ -47,16 +44,16 @@ jobs: runs-on: ubuntu-latest steps: - name: checkout - uses: actions/checkout@master + uses: actions/checkout@v4 - name: restore cache from package-lock.json - uses: actions/cache@v2 + uses: actions/cache@v4 with: path: package-temp-dir key: lock-${{ github.sha }} - name: restore cache from node_modules - uses: actions/cache@v2 + uses: actions/cache@v4 with: path: node_modules key: node_modules-${{ hashFiles('**/package-temp-dir/package-lock.json') }} @@ -70,16 +67,16 @@ jobs: runs-on: ubuntu-latest steps: - name: checkout - uses: actions/checkout@master + uses: actions/checkout@v4 - name: restore cache from package-lock.json - uses: actions/cache@v2 + uses: actions/cache@v4 with: path: package-temp-dir key: lock-${{ github.sha }} - name: restore cache from node_modules - uses: actions/cache@v2 + uses: actions/cache@v4 with: path: node_modules key: node_modules-${{ hashFiles('**/package-temp-dir/package-lock.json') }} @@ -93,21 +90,26 @@ jobs: runs-on: ubuntu-latest steps: - name: checkout - uses: actions/checkout@master + uses: actions/checkout@v4 - name: restore cache from package-lock.json - uses: actions/cache@v2 + uses: actions/cache@v4 with: path: package-temp-dir key: lock-${{ github.sha }} - name: restore cache from node_modules - uses: actions/cache@v2 + uses: actions/cache@v4 with: path: node_modules key: node_modules-${{ hashFiles('**/package-temp-dir/package-lock.json') }} - name: coverage - run: npm test -- --coverage && bash <(curl -s https://codecov.io/bash) + run: npm test -- --coverage + + - name: Upload coverage to Codecov + uses: codecov/codecov-action@v4 + with: + token: ${{ secrets.CODECOV_TOKEN }} - needs: setup \ No newline at end of file + needs: setup From edb2ab75de299b6e8a6f12ad932ec5346c0d3ed8 Mon Sep 17 00:00:00 2001 From: Victor Rudolfsson Date: Thu, 22 Aug 2024 12:38:35 +1000 Subject: [PATCH 4/4] fix: Luxon AM/PM formatting (#862) --- src/generate/luxon.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/generate/luxon.ts b/src/generate/luxon.ts index cd1def454..dffa4acf3 100644 --- a/src/generate/luxon.ts +++ b/src/generate/luxon.ts @@ -25,7 +25,8 @@ const normalizeFormatPart = (part: string): string => .replace(/D/g, 'd') .replace(/gg/g, 'kk') .replace(/Q/g, 'q') - .replace(/([Ww])o/g, 'WW'); + .replace(/([Ww])o/g, 'WW') + .replace(/A/g, 'a'); /** * Normalizes a moment compatible format string to a luxon compatible format string