bito-code-review[bot] commented on code in PR #38470:
URL: https://github.com/apache/superset/pull/38470#discussion_r2895769616
##########
superset-frontend/src/filters/components/Select/SelectFilterPlugin.tsx:
##########
@@ -504,39 +547,57 @@ export default function PluginFilterSelect(props:
PluginFilterSelectProps) {
onChange={handleExclusionToggle}
/>
)}
- <Select
- name={formData.nativeFilterId}
- allowClear
- allowNewOptions={!searchAllOptions && creatable !== false}
- allowSelectAll={!searchAllOptions}
- value={multiSelect ? filterState.value || [] : filterState.value}
- disabled={isDisabled}
- getPopupContainer={
- showOverflow
- ? () => (parentRef?.current as HTMLElement) || document.body
- : (trigger: HTMLElement) =>
- (trigger?.parentNode as HTMLElement) || document.body
- }
- showSearch={showSearch}
- mode={multiSelect ? 'multiple' : 'single'}
- placeholder={placeholderText}
- onClear={() => onSearch('')}
- onSearch={onSearch}
- onBlur={handleBlur}
- onFocus={setFocusedFilter}
- onMouseEnter={setHoveredFilter}
- onMouseLeave={unsetHoveredFilter}
- // @ts-expect-error
- onChange={handleChange}
- ref={inputRef}
- loading={isRefreshing}
- oneLine={filterBarOrientation === FilterBarOrientation.Horizontal}
- invertSelection={inverseSelection && excludeFilterValues}
- options={options}
- sortComparator={sortComparator}
- onOpenChange={setFilterActive}
- className="select-container"
- />
+ {isLikeOperator ? (
+ <Input
+ allowClear
+ placeholder={likeInputPlaceholder}
+ defaultValue={
+ filterState.value?.[0] != null
+ ? String(filterState.value[0])
+ : undefined
+ }
+ onChange={handleLikeInputChange}
+ onFocus={setFocusedFilter}
+ onBlur={unsetFocusedFilter}
+ onMouseEnter={setHoveredFilter}
+ onMouseLeave={unsetHoveredFilter}
+ disabled={isDisabled}
+ />
Review Comment:
<div>
<div id="suggestion">
<div id="issue"><b>Uncontrolled input inconsistency</b></div>
<div id="fix">
The Input component uses defaultValue, making it uncontrolled and
inconsistent with the controlled Select. If filterState.value changes
externally (e.g., filter reset), the input won't update, potentially showing
stale data. This differs from Select, which reflects changes immediately. To
fix, add a local state for the input value and make the Input controlled.
</div>
</div>
<small><i>Code Review Run #45eb5e</i></small>
</div>
---
Should Bito avoid suggestions like this for future reviews? (<a
href=https://alpha.bito.ai/home/ai-agents/review-rules>Manage Rules</a>)
- [ ] Yes, avoid them
--
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]