mirror of
https://github.com/apache/superset.git
synced 2026-05-11 10:55:43 +00:00
fix(explore): don't respect y-axis formatting (#29367)
This commit is contained in:
@@ -17,7 +17,7 @@
|
||||
* under the License.
|
||||
*/
|
||||
import { defaultState } from 'src/explore/store';
|
||||
import { render } from 'spec/helpers/testing-library';
|
||||
import { render, waitFor } from 'spec/helpers/testing-library';
|
||||
import { useSelector } from 'react-redux';
|
||||
import { ExplorePageState } from 'src/explore/types';
|
||||
import StashFormDataContainer from '.';
|
||||
@@ -54,3 +54,31 @@ test('should stash form data from fieldNames', () => {
|
||||
'granularity_sqla',
|
||||
);
|
||||
});
|
||||
|
||||
test('should restore form data from fieldNames', async () => {
|
||||
const { granularity_sqla, ...formData } = defaultState.form_data;
|
||||
const { container } = render(
|
||||
<StashFormDataContainer
|
||||
shouldStash={false}
|
||||
fieldNames={['granularity_sqla']}
|
||||
>
|
||||
<FormDataMock />
|
||||
</StashFormDataContainer>,
|
||||
{
|
||||
useRedux: true,
|
||||
initialState: {
|
||||
explore: {
|
||||
form_data: formData,
|
||||
hiddenFormData: {
|
||||
granularity_sqla,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
);
|
||||
await waitFor(() =>
|
||||
expect(container.querySelector('div')).toHaveTextContent(
|
||||
'granularity_sqla',
|
||||
),
|
||||
);
|
||||
});
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
import { useEffect, useRef, FC } from 'react';
|
||||
import { useEffect, FC } from 'react';
|
||||
|
||||
import { useDispatch } from 'react-redux';
|
||||
import { setStashFormData } from 'src/explore/actions/exploreActions';
|
||||
@@ -33,16 +33,11 @@ const StashFormDataContainer: FC<Props> = ({
|
||||
children,
|
||||
}) => {
|
||||
const dispatch = useDispatch();
|
||||
const isMounted = useRef(false);
|
||||
const onVisibleUpdate = useEffectEvent((shouldStash: boolean) =>
|
||||
dispatch(setStashFormData(shouldStash, fieldNames)),
|
||||
);
|
||||
useEffect(() => {
|
||||
if (!isMounted.current && !shouldStash) {
|
||||
isMounted.current = true;
|
||||
} else {
|
||||
onVisibleUpdate(shouldStash);
|
||||
}
|
||||
onVisibleUpdate(shouldStash);
|
||||
}, [shouldStash, onVisibleUpdate]);
|
||||
|
||||
return <>{children}</>;
|
||||
|
||||
Reference in New Issue
Block a user