diff --git a/apps/spreadsheeteditor/mobile/src/controller/FilterOptions.jsx b/apps/spreadsheeteditor/mobile/src/controller/FilterOptions.jsx index 1a214d32c..2d3cd2bd8 100644 --- a/apps/spreadsheeteditor/mobile/src/controller/FilterOptions.jsx +++ b/apps/spreadsheeteditor/mobile/src/controller/FilterOptions.jsx @@ -1,4 +1,4 @@ -import React, { useEffect,useState } from 'react'; +import React, { useEffect,useRef,useState } from 'react'; import FilterView from '../../src/view/FilterOptions'; import { f7,Sheet,Popover } from 'framework7-react'; import { Device } from '../../../../common/mobile/utils/device'; @@ -7,12 +7,12 @@ import { useTranslation } from 'react-i18next'; const FilterOptionsController = () => { const { t } = useTranslation(); const _t = t('View.Edit', {returnObjects: true}); + const configRef = useRef(); - const [configFilter, setConfig] = useState(null); const [listVal, setListValue] = useState([]); const [isValid, setIsValid] = useState(null); - const [checkSort, setCheckSort] = useState(null); - + const [checkSort, setCheckSort] = useState(''); + useEffect(() => { function onDocumentReady() { const api = Common.EditorApi.get(); @@ -34,9 +34,8 @@ const FilterOptionsController = () => { const onApiFilterOptions= (config) => { setDataFilterCells(config); - setConfig(config); - setClearDisable(config); - + configRef.current = config; + setCheckSort((config.asc_getSortState() === Asc.c_oAscSortOptions.Ascending ? 'down' : '') || (config.asc_getSortState() === Asc.c_oAscSortOptions.Descending ? 'up' : '')); @@ -55,7 +54,7 @@ const FilterOptionsController = () => { const onSort = (type) => { const api = Common.EditorApi.get(); - api.asc_sortColFilter(type == 'sortdown' ? Asc.c_oAscSortOptions.Ascending : Asc.c_oAscSortOptions.Descending, configFilter.asc_getCellId(), configFilter.asc_getDisplayName()); + api.asc_sortColFilter(type == 'sortdown' ? Asc.c_oAscSortOptions.Ascending : Asc.c_oAscSortOptions.Descending, configRef.current.asc_getCellId(), configRef.current.asc_getDisplayName()); f7.sheet.close('.picker__sheet'); f7.popover.close('#picker-popover'); }; @@ -112,15 +111,15 @@ const FilterOptionsController = () => { setListValue([...listVal]); if ( listVal.some(item => item.check) ) { - configFilter.asc_getValues().forEach( + configRef.current.asc_getValues().forEach( (item, index) => item.asc_setVisible(listVal[index].check) ); - configFilter.asc_getFilterObj().asc_setType(Asc.c_oAscAutoFilterTypes.Filters); - api.asc_applyAutoFilter(configFilter); + configRef.current.asc_getFilterObj().asc_setType(Asc.c_oAscAutoFilterTypes.Filters); + api.asc_applyAutoFilter(configRef.current); } - setClearDisable(configFilter); + setClearDisable(configRef.current); }; return ( diff --git a/apps/spreadsheeteditor/mobile/src/page/main.jsx b/apps/spreadsheeteditor/mobile/src/page/main.jsx index a58b7d571..1551f1503 100644 --- a/apps/spreadsheeteditor/mobile/src/page/main.jsx +++ b/apps/spreadsheeteditor/mobile/src/page/main.jsx @@ -103,7 +103,6 @@ class MainPage extends Component { this.handleClickToOpenOptions('add', {panels: panels, button: button})}/> - {/* Page content */} {showPlaceholder ? @@ -131,7 +130,9 @@ class MainPage extends Component { } - + {!appOptions.isDocReady ? null : + + } diff --git a/apps/spreadsheeteditor/mobile/src/view/FilterOptions.jsx b/apps/spreadsheeteditor/mobile/src/view/FilterOptions.jsx index ea12db905..20b77dc1f 100644 --- a/apps/spreadsheeteditor/mobile/src/view/FilterOptions.jsx +++ b/apps/spreadsheeteditor/mobile/src/view/FilterOptions.jsx @@ -55,7 +55,7 @@ const FilterOptions = (props) => { - {_t.textClearFilter} + {_t.textClearFilter} props.onDeleteFilter()} id="btn-delete-filter">{_t.textDeleteFilter}