-
Notifications
You must be signed in to change notification settings - Fork 440
Feat/fix select default search #4639
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weโll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
/next |
|
Warning Rate limit exceeded@MMhunter has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 18 minutes and 24 seconds before requesting another review. โ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. ๐ฆ How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ๐ Files selected for processing (2)
Walkthroughไธบ Select ็ปไปถๆฐๅข externalSearchBehavior ๅ ฌๆๅฑๆงๅนถ่ฐๆดๆ็ดขๆธฒๆ้ป่พ๏ผๅจ FileDialog ไธญไธบ็ฎๅฝ้ๆฉ Select ๅฏ็จ่ฏฅๅฑๆง๏ผๅจ TabbarService ็ onResize ไธญๅฐๅฏน currentContainerId ็่ฎฟ้ฎๆนไธบไฝฟ็จ get() ่ทๅๅผใ Changes
Sequence Diagram(s)sequenceDiagram
actor User as ็จๆท
participant Select as Select็ปไปถ
participant Consumer as ๅค้จๆ็ดขๆงๅถๆน
participant List as SelectOptionsList
User->>Select: ่พๅ
ฅๆ็ดขๅ
ณ้ฎๅญ
Select->>Consumer: ่งฆๅ onSearchChange(keyword)๏ผ่ฅๆไพ๏ผ
alt externalSearchBehavior ไธบ true ไธ keyword ้็ฉบ
Note over Select,Consumer: ๅค้จๆฅ็ฎก่ฟๆปค/็ปๆๅฑ็คบ
Select--xList: ไธๆธฒๆไธๆๅ่กจ
else ๅ
ถไปๆ
ๅต
Select->>List: ๆธฒๆๅนถๆๅ
้จ้ป่พๅฑ็คบ้้กน
end
Estimated code review effort๐ฏ 3 (Moderate) | โฑ๏ธ ~20 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Pre-merge checks and finishing touchesโ Failed checks (1 warning, 1 inconclusive)
โ Passed checks (1 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
Caution
Some comments are outside the diff and canโt be posted inline due to platform limitations.
โ ๏ธ Outside diff range comments (2)
packages/components/src/select/index.tsx (1)
425-429: ๆ็ดข่พๅ ฅๆช้ไธๆๅ ณ้ญๆธ ็ฉบ๏ผไพ่ตๆฐ็ป็ผบๅคฑๅฏผ่ด้ป่พๅคฑๆ่ฏฅๅฏไฝ็จๅชๅจ้ฆๆฌกๆ่ฝฝๆง่กไธๆฌก๏ผๆ ๆณๅจๅ ณ้ญ้ขๆฟๆถๆธ ็ฉบ
searchInput๏ผ็ปๅโๅฏ็จๅค้จๆ็ดขๆถๆ่พๅ ฅๅฐฑไธๆธฒๆๅ่กจโ็้ป่พ๏ผๅฏ่ฝๅฏผ่ดๅๆฌกๆๅผๅๅ่กจไธ็ดไธๆพ็คบใ- useEffect(() => { - if (!open && searchInput) { - setSearchInput(''); - } - }, []); + useEffect(() => { + if (!open && searchInput) { + setSearchInput(''); + } + }, [open, searchInput]);packages/file-tree-next/src/browser/dialog/file-dialog.view.tsx (1)
170-181: ้่ฏฏไฝฟ็จไบๆชๅฎไน็eventๅ้๏ผๆๅผๅ้ป่พ้่ฏฏๅ่ฐๅๆฐๅไธบ
ev๏ผไฝ่ฟ้่ฐ็จไบhasShiftMask(event)/hasCtrlCmdMask(event)ใๅจ React ็ฏๅขไธwindow.eventไธๅฏ้ ๏ผ่ฟไผๅฏผ่ดไฟฎ้ฅฐ้ฎๅคๆญๅผๅธธใ- const shiftMask = hasShiftMask(event); - const ctrlCmdMask = hasCtrlCmdMask(event); + const shiftMask = hasShiftMask(ev); + const ctrlCmdMask = hasCtrlCmdMask(ev);
๐งน Nitpick comments (7)
packages/main-layout/src/browser/tabbar/tabbar.service.ts (1)
831-841: ๆน็จ.get()่ฏปๅ currentContainerId ็ไฟฎๅคๆฏๅ็็๏ผๅปบ่ฎฎไธๆฌก่ฏปๅๅนถๅค็จไปฅ้ฟๅ ็ถๆๆๅจๅฝๅๅจๅไธ่ฝฎๆง่กไธญๅฏน
this.currentContainerId.get()่ฏปๅไบไธคๆฌก๏ผๆ็ซฏๆ ๅตไธๅฏ่ฝๅบ็ฐๅๅไธไธ่ด๏ผไพๅฆๅๆขๅ็ๅจfastdomๅ่ฐ้ด้๏ผ๏ผไนไผไบง็ไธๆฌกไธๅฟ ่ฆ็ observable ่ฏปๅใๅปบ่ฎฎๅฐๅผ็ผๅญๅฐๅฑ้จๅ้ๅนถๅค็จ๏ผ่ฏญไนๆด็จณๅฎไนๆดๆ่ฏปใfastdom.measureAtNextFrame(() => { - if (!this.currentContainerId.get() || !this.resizeHandle) { + const currentId = this.currentContainerId.get(); + if (!currentId || !this.resizeHandle) { // ๆๅ ๆถไธ็ๅฌๅๅ return; } const size = this.resizeHandle.getSize(); - if (size !== this.barSize && !this.shouldExpand(this.currentContainerId.get())) { + if (size !== this.barSize && !this.shouldExpand(currentId)) { this.prevSize = size; this.onSizeChangeEmitter.fire({ size }); } });packages/components/src/select/index.tsx (4)
536-536: ้่ไธๆๅ่กจ็ๆกไปถๅปบ่ฎฎๆน็จๆดพ็ๅธธ้๏ผๅนถ่ฏท็กฎ่ฎคไบคไบๆฏๅฆ็ฌฆๅ้ขๆๅฝๅๆกไปถๅจๆ่พๅ ฅไธๅฏ็จๅค้จๆ็ดขๆถๅฎๅ จไธๆธฒๆๅ่กจ๏ผๅฏ่ฝๅฏผ่ด็จๆท่พๅ ฅๆ้ดๆ ๅฏ้็ปๆๅฏ่ง/ๅฏ่พพใ่ฅๅค้จไผๆ่พๅ ฅๅผๆญฅๅทๆฐ
options๏ผ้ๅธธไปๅธๆๅฑ็คบๆดๆฐๅ็ๅ่กจใๅปบ่ฎฎๅ ๆน็จๅฑ้จๅธธ้๏ผไบคไบๅฑ้ข่ฏท็กฎ่ฎค๏ผๆฏๅฆ้่ฆโๆญฃๅจๆ็ดขโฆโๅ ไฝๆไฟ็ไธๆฌก็ปๆใ
- !(externalSearchBehavior && searchInput) && + !(isExternalSearch && searchInput) &&ๅฆ้ไฟ็ๆธฒๆๅนถไบค็ปๅค้จ่ฟๆปค๏ผๅฏๆนไธบๅง็ปๆธฒๆๅนถ็ฑๅค้จๆงๅถ
optionsๅ ๅฎนใ้่ฆ็่ฏๆๅฏไปฅ่กฅๆไบคโๆ็ดขไธญๅ ไฝ + ็ฉบๆโๆนๆกใ
484-508: ๅค้จๆ็ดขๅฏ็จๆถๅฏ้ฟๅ ไธๅฟ ่ฆ็ๆฌๅฐ่ฟๆปค่ฎก็ฎๅฝ
isExternalSearch && searchInputๆถๆฌๅฐfilterOption็ปๆไธไผ่ขซๆธฒๆ๏ผไป่ฎก็ฎไผๅนณ็ฝไบง็ๅผ้ใ- const filteredOptions = useMemo(() => { + const filteredOptions = useMemo(() => { + if (isExternalSearch && searchInput) { + // ๅค้จๆ็ฎก่ฟๆปค๏ผ็ดๆฅ่ฟๅๅ options๏ผๆๅค้จไผ ๅ ฅ็็ปๆ๏ผ + return options; + } if (!searchInput) { return options; } @@ - }, [options, searchInput, filterOption]); + }, [options, searchInput, filterOption, isExternalSearch]);
516-522: useCallback ไพ่ตๅ ๅซๆ ็จ็searchInputๅ่ฐๅ ๆช่ฏปๅ
searchInput๏ผๅฐๅ ถๆพๅ ฅไพ่ตไผ้ ๆไธๅฟ ่ฆ็้ๅปบใ- }, [searchInput, onSearchChange], + }, [onSearchChange],
30-33: ่กฅๅ ๅค้จๆ็ดขๅผๅ ณ็้ป่ฎค่ฏญไนๅฐๆณจ้ไธบ้ฟๅ ๆญงไน๏ผๅปบ่ฎฎๅจๆณจ้ไธญๆ็กฎโๆชๆพๅผไผ ๅ ฅๆถ๏ผ่ฅๆไพ
onSearchChangeๅ้ป่ฎคๅฏ็จโใ/** - * ๆ็ดข่กไธบไธ้็จ้ป่ฎค็ filterOptions ่ฟ่ก็ญ้๏ผ็ฑๅค้จๆ็ฎก + * ๆ็ดข่กไธบ็ฑๅค้จๆ็ฎก๏ผไธไฝฟ็จ้ป่ฎค filterOption๏ผใ + * ๆชๆพๅผไผ ๅ ฅๆถ๏ผ่ฅๆไพ onSearchChange ๅ้ป่ฎคๅฏ็จใ */ externalSearchBehavior?: boolean;packages/file-tree-next/src/browser/dialog/file-dialog.view.tsx (2)
291-291: ๆญคๅคๅฏ็็ฅexternalSearchBehavior๏ผๅฏ้๏ผๅจ Select ไธญๆไปฌๅทฒ็บฆๅฎโๆชๆพๅผไผ ๅ ฅๆถ๏ผๆไพไบ
onSearchChangeๅ้ป่ฎคๅฏ็จๅค้จๆ็ดขโ๏ผๅ ๆญค่ฟ้ๅฏไปฅไธๅฟ ๆพๅผไผtrue๏ผ้ฟๅ ๆ ทๆฟไปฃ็ ใ- externalSearchBehavior={true} + // ็็ฅ๏ผๆไพไบ onSearchChange๏ผ้ป่ฎคๅฏ็จๅค้จๆ็ดข
224-232: ็ฎๅฝ่ทฏๅพๆ็ดขๆฏๅป้ฎๅณ่งฆๅๆ ๆจกๅๅทๆฐ๏ผๅปบ่ฎฎๅปๆ้ข็น่ฐ็จ
updateTreeModelๅฏ่ฝๅผๅๆง่ฝๆๅจใๅปบ่ฎฎๅฏนonSearchChangeHandlerๅ่ฝป้ๅปๆ๏ผ200ms ไฝไธบ่ตท็น๏ผ๏ผๅๆถ็ฒพ็ฎไพ่ตใ- const onSearchChangeHandler = useCallback( - async (value: string) => { - setIsReady(false); - setSelectPath(value); - await model.updateTreeModel(value); - setIsReady(true); - }, - [model, isReady, selectPath, directoryList], - ); + const debounceRef = useRef<number | null>(null); + const onSearchChangeHandler = useCallback( + (value: string) => { + if (debounceRef.current) { + window.clearTimeout(debounceRef.current); + } + debounceRef.current = window.setTimeout(async () => { + setIsReady(false); + setSelectPath(value); + await model.updateTreeModel(value); + setIsReady(true); + }, 200); + }, + [model], + );
๐ Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
๐ Files selected for processing (3)
packages/components/src/select/index.tsx(3 hunks)packages/file-tree-next/src/browser/dialog/file-dialog.view.tsx(1 hunks)packages/main-layout/src/browser/tabbar/tabbar.service.ts(1 hunks)
โฐ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (7)
- GitHub Check: build (macos-latest, 20.x)
- GitHub Check: build (ubuntu-latest, 20.x)
- GitHub Check: unittest (macos-latest, 18.x, jsdom)
- GitHub Check: unittest (ubuntu-latest, 18.x, node)
- GitHub Check: unittest (ubuntu-latest, 18.x, jsdom)
- GitHub Check: unittest (macos-latest, 18.x, node)
- GitHub Check: ubuntu-latest, Node.js 20.x
| externalSearchBehavior = externalSearchBehavior || !!onSearchChange | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
้ป่ฎคๅผ่ฆ็ๆพๅผ false๏ผไธ็ดๆฅๆนๅๅๆฐ๏ผๅญๅจ่ฏญไนไธๅฏ็ปดๆคๆง้ฎ้ข
- ไฝฟ็จ
||ไผๅจonSearchChangeๅญๅจๆถๆ็จๆทๆพๅผไผ ๅ ฅ็false่ฆ็ๆtrue๏ผ่ฟไธ็ฌฆๅ็ด่งใ - ไธ่ฆ็ดๆฅ้ๅๅฝๆฐๅๆฐ๏ผๆน็จๆดพ็็ๅฑ้จๅธธ้ๆดๅฎๅ จๆธ ๆฐใ
ๅปบ่ฎฎ๏ผ็จ็ฉบๅผๅๅนถๅนถๅผๅ
ฅๅฑ้จๅ้๏ผๆขไฟ็โๅฝๆชๆพๅผไผ ๅผๆถ้ป่ฎค้ onSearchChange ๅฏ็จโ็่ฏญไน๏ผไนๅฐ้ๆพๅผ falseใ
export function Select<T = string>({
@@
onSearchChange,
- externalSearchBehavior
+ externalSearchBehavior
}: ISelectProps<T>) {
@@
- externalSearchBehavior = externalSearchBehavior || !!onSearchChange
+ // ๆดพ็ๅค้จๆ็ดขๅผๅ
ณ๏ผๆชๆพๅผไผ ๅ
ฅๆถ๏ผ้ป่ฎค้ onSearchChange ๅฏ็จ๏ผๆพๅผ false ๅฟ
้กป่ขซๅฐ้
+ const isExternalSearch = externalSearchBehavior ?? !!onSearchChange;ๅนถๅๆญฅๆฟๆขๅ็ปญๅฏน externalSearchBehavior ็ไฝฟ็จ๏ผ่งไธๆน็ธๅ
ณ diff๏ผใ
Also applies to: 297-298
๐ค Prompt for AI Agents
In packages/components/src/select/index.tsx around lines 297-306, the code
mutates the parameter and uses `||` which erroneously treats an explicit false
as missing; change to derive a local constant using nullish coalescing (e.g.
const resolvedExternalSearchBehavior = externalSearchBehavior ??
!!onSearchChange) so an explicit false is preserved and you donโt overwrite the
parameter, and then update all subsequent references to use this new local
constant instead of the original parameter.
f9d6550 to
9ecabc3
Compare
|
๐ PR Next publish successful! 3.9.1-next-1759129101.0 |
9ecabc3 to
a276714
Compare
Codecov Reportโ
All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #4639 +/- ##
========================================
Coverage 52.59% 52.60%
========================================
Files 1686 1686
Lines 104362 104362
Branches 22682 22830 +148
========================================
+ Hits 54894 54901 +7
+ Misses 41097 41091 -6
+ Partials 8371 8370 -1
Flags with carried forward coverage won't be shown. Click here to find out more. โ View full report in Codecov by Sentry. ๐ New features to boost your workflow:
|
Types
Background or solution
ไฟฎๅค็ฑ #4306 ๅผๅ ฅ็ๅๆๆ็ดขๆงไปถ็ๆ็ดข็ญ้ๅ่ฝๅฎๆ้ฎ้ข
Changelog
Summary by CodeRabbit