mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-08-09 13:15:51 +08:00
feat(core): draft filter skip method step if there is only one method (#12457)
<!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Filter options can now start from a specified step, improving flexibility when multiple filtering methods are available. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
@@ -39,6 +39,7 @@ export const Condition = ({
|
|||||||
<FilterOptionsGroup
|
<FilterOptionsGroup
|
||||||
isDraft={isDraft}
|
isDraft={isDraft}
|
||||||
onDraftCompleted={onDraftCompleted}
|
onDraftCompleted={onDraftCompleted}
|
||||||
|
initialStep={methods && methods.length > 1 ? 0 : 1}
|
||||||
items={[
|
items={[
|
||||||
methods &&
|
methods &&
|
||||||
(({ onDraftCompleted, menuRef }) => {
|
(({ onDraftCompleted, menuRef }) => {
|
||||||
|
|||||||
@@ -13,10 +13,12 @@ export const FilterOptionsGroup = ({
|
|||||||
isDraft,
|
isDraft,
|
||||||
onDraftCompleted,
|
onDraftCompleted,
|
||||||
items,
|
items,
|
||||||
|
initialStep = 0,
|
||||||
}: {
|
}: {
|
||||||
isDraft?: boolean;
|
isDraft?: boolean;
|
||||||
onDraftCompleted?: () => void;
|
onDraftCompleted?: () => void;
|
||||||
items?: FilterOptionsGroupChildren[];
|
items?: FilterOptionsGroupChildren[];
|
||||||
|
initialStep?: number;
|
||||||
}) => {
|
}) => {
|
||||||
const stepCount =
|
const stepCount =
|
||||||
items?.filter(v => {
|
items?.filter(v => {
|
||||||
@@ -27,7 +29,7 @@ export const FilterOptionsGroup = ({
|
|||||||
}).length ?? 0;
|
}).length ?? 0;
|
||||||
|
|
||||||
const childRefs = useRef<(MenuRef | null)[]>([]);
|
const childRefs = useRef<(MenuRef | null)[]>([]);
|
||||||
const [currentStep, setCurrentStep] = useState(0);
|
const [currentStep, setCurrentStep] = useState(initialStep);
|
||||||
|
|
||||||
const handleNextStep = useCallback(() => {
|
const handleNextStep = useCallback(() => {
|
||||||
// Add a small delay between steps to prevent the next menu from automatically closing due to the previous menu's close event
|
// Add a small delay between steps to prevent the next menu from automatically closing due to the previous menu's close event
|
||||||
|
|||||||
Reference in New Issue
Block a user