Skip to content

Commit

Permalink
Merge pull request #415 from Kanaries/fix-select-data
Browse files Browse the repository at this point in the history
fix: data crash when import data
  • Loading branch information
ObservedObserver authored Jun 27, 2024
2 parents d6200bf + 554f6f5 commit 92096c6
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
19 changes: 18 additions & 1 deletion packages/rath-client/src/pages/dataSource/dataTable/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ const ADD_BATCH_SIZE = 5;

const DataTable: React.FC = (props) => {
const { dataSourceStore } = useGlobalStore();
const { filteredDataMetaInfo, fieldsWithExtSug: fields, filteredDataStorage } = dataSourceStore;
const { filteredDataMetaInfo, fieldsWithExtSug: fields, filteredDataStorage, datasetId } = dataSourceStore;
const [filteredData, setFilteredData] = useState<IRow[]>([]);
const [textSelectList, setTextSelectList] = useState<IFieldTextSelection[]>([]);
const [editTP, setEditTP] = useState<boolean>(false);
Expand All @@ -68,6 +68,23 @@ const DataTable: React.FC = (props) => {
specific: 1,
nlp: 1,
});
useEffect(() => {
// clean state
setFilteredData([]);
setTextSelectList([]);
setEditTP(false);
setGroupedTextPatternList(initGroupedTextPatternList());
setTpPos({
groupKey: 'knowledge',
index: 0,
});
setGroupShownSize({
knowledge: 1,
generalize: 1,
specific: 1,
nlp: 1,
});
}, [datasetId]);

const tsList2tpList = useCallback((tsl: IFieldTextSelection[]) => {
try {
Expand Down
1 change: 1 addition & 0 deletions packages/rath-client/src/store/dataSourceStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -515,6 +515,7 @@ export class DataSourceStore {
public async loadDataWithInferMetas (dataSource: IRow[], fields: IMuteFieldBase[], tag?: DataSourceTag | undefined) {
if (fields.length > 0 && dataSource.length > 0) {
const metas = await inferMetaService({ dataSource, fields })
this.initStore()
// vega-lite's title contains \n will fail to render
// fix: https://github.com/Kanaries/Rath/issues/381
metas.forEach(m => {
Expand Down

0 comments on commit 92096c6

Please sign in to comment.