sadpandajoe commented on code in PR #44945: URL: https://github.com/apache/superset/pull/44945#discussion_r4266796574
########## superset-frontend/src/explore/components/controls/ColumnConfigControl/ControlForm/ControlForm.test.tsx: ########## @@ -0,0 +1,83 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +import { fireEvent, render, screen, act } from 'spec/helpers/testing-library'; +import ControlForm, { ControlFormItem, ControlFormRow } from './index'; + +test('commits displayed default when clicking default option without initial value', () => { + jest.useFakeTimers(); + const onChange = jest.fn(); + const { rerender } = render( + <ControlForm onChange={onChange}> + <ControlFormRow> + <ControlFormItem Review Comment: Both `ControlFormItem` instances here (this one and the rerender at line 58) omit the required `description` prop, so `lint-frontend` fails `tsc` with TS2322 at both locations and the PR can't pass CI. Can you pass `description=""` (or whatever the other call sites use) on both? ########## superset-frontend/packages/superset-ui-chart-controls/src/shared-controls/components/RadioButtonControl.tsx: ########## @@ -95,7 +104,9 @@ export default function RadioButtonControl({ }`} onClick={e => { e.currentTarget?.focus(); - onChange(val); + if (isUnpersistedDefault && val === currentValue) { Review Comment: The commit-on-click guard keys on `value === undefined`, but the displayed option falls back via `value ?? firstOption`. With `value={null}` the first option shows as selected, yet neither `Radio.Group` (already selected) nor this guard (`null !== undefined`) fires, so clicking it can't commit the displayed default; before this change it did. Should the unpersisted check be `value == null` (and likewise for `initialValue`) so a null/unset value is treated the same? -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
