Skip to content
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

fix(sheets-filter-ui): fix the react compatibility issue with sheets filter #4189

Merged
merged 1 commit into from
Nov 30, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,10 @@ export function FilterByCondition(props: { model: ByConditionsModel }) {
const localeService = useDependency(LocaleService);

// form state is from the model
const condition = useObservable(model.conditionItem$, undefined, true);
const formParams = useObservable(model.filterConditionFormParams$, undefined, true);
const { operator, numOfParameters } = condition;
const { operator1, operator2, val1, val2, and } = formParams;
const condition = useObservable(model.conditionItem$, undefined);
const formParams = useObservable(model.filterConditionFormParams$, undefined);

const radioValue = and ? 'AND' : 'OR';
const radioValue = formParams?.and ? 'AND' : 'OR';
const onRadioChange = useCallback((key: string | number | boolean) => {
model.onConditionFormChange({ and: key === 'AND' });
}, [model]);
Expand Down Expand Up @@ -79,20 +77,24 @@ export function FilterByCondition(props: { model: ByConditionsModel }) {
return (
<div className={styles.sheetsFilterPanelConditionsContainer}>
{/* primary condition */}
<Select value={operator} options={primaryOptions} onChange={onPrimaryConditionChange} />
{FilterConditionItems.getItemByOperator(operator).numOfParameters !== 0
? (
<div className={styles.sheetsFilterPanelConditionsContainerInner}>
{numOfParameters >= 1 && renderSecondaryCondition(operator1!, val1 ?? '', 'operator1')}
{numOfParameters >= 2 && renderSecondaryCondition(operator2!, val2 ?? '', 'operator2')}
<div className={styles.sheetsFilterPanelConditionsDesc}>
{localeService.t('sheets-filter.panel.?')}
<br></br>
{localeService.t('sheets-filter.panel.*')}
</div>
</div>
)
: null}
{(condition && formParams) && (
<>
<Select value={condition.operator} options={primaryOptions} onChange={onPrimaryConditionChange} />
{FilterConditionItems.getItemByOperator(condition.operator).numOfParameters !== 0
? (
<div className={styles.sheetsFilterPanelConditionsContainerInner}>
{condition.numOfParameters >= 1 && renderSecondaryCondition(formParams.operator1!, formParams.val1 ?? '', 'operator1')}
{condition.numOfParameters >= 2 && renderSecondaryCondition(formParams.operator2!, formParams.val2 ?? '', 'operator2')}
<div className={styles.sheetsFilterPanelConditionsDesc}>
{localeService.t('sheets-filter.panel.?')}
<br></br>
{localeService.t('sheets-filter.panel.*')}
</div>
</div>
)
: null}
</>
)}
</div>
);
}
Expand Down