Copilot commented on code in PR #11711:
URL: https://github.com/apache/gravitino/pull/11711#discussion_r3426504022
##########
web-v2/web/src/components/SecurableObjectFormFields.js:
##########
@@ -443,6 +445,40 @@ export default function SecurableObjectFormFields({
fieldName, fieldKey, metalak
}
}
+ const searchSchemas = async (catalog, searchText) => {
+ if (!catalog) return
+ setSchemasLoading(true)
+ try {
+ const parts = String(searchText || '').split(':')
+ const filterText = parts.pop() || ''
+ const parentSchema = parts.length > 0 ? parts.join(':') : undefined
+
Review Comment:
The hierarchical schema separator is hard-coded as ':' when parsing search
input (split/join). The server-side separator is configurable via
`gravitino.schema.separator` (default `:`), and the UI already reads this
setting in CreateSchemaDialog. Hard-coding ':' here will break schema
search/selection when a non-default separator is configured.
##########
web-v2/web/src/components/SecurableObjectFormFields.js:
##########
@@ -631,13 +667,17 @@ export default function SecurableObjectFormFields({
fieldName, fieldKey, metalak
</Select>
Review Comment:
If the user changes the catalog while a schema search debounce is pending,
the scheduled search can still run and overwrite the schemas for the newly
selected catalog. Clear any pending schema-search timeout when catalog changes
to prevent stale results.
##########
web-v2/web/src/components/SecurableObjectFormFields.js:
##########
@@ -73,6 +74,7 @@ export default function SecurableObjectFormFields({
fieldName, fieldKey, metalak
const [localRemoteLoading, setLocalRemoteLoading] = useState({})
const catalogOptions = localRemoteOptions['catalog'] || []
const rootRef = useRef(null)
+ const schemaSearchTimerRef = useRef(null)
Review Comment:
The debounced schema search timeout isn't cleared on unmount. If the user
navigates away while a search is scheduled, the timeout can still fire and
trigger a state update on an unmounted component.
##########
web-v2/web/src/components/SecurableObjectFormFields.js:
##########
@@ -718,12 +758,17 @@ export default function SecurableObjectFormFields({
fieldName, fieldKey, metalak
</Select>
<Select
showSearch
- filterOption={(input, option) =>
-
String(option.label).toLowerCase().includes(String(input).toLowerCase())
- }
+ filterOption={false}
placeholder={`Please search or select schema name`}
loading={schemasLoading}
value={localSchemaVal}
+ onSearch={val => {
+ if (val) {
+ debouncedSearchSchemas(localCatalogVal, val)
+ } else if (localCatalogVal) {
+ loadSchemasForCatalog(localCatalogVal)
+ }
+ }}
Review Comment:
When the schema search box is cleared, a previously scheduled debounced
search can still fire and overwrite the full schema list loaded by
`loadSchemasForCatalog`. Clear any pending schema-search timeout before
reloading the full list.
##########
web-v2/web/src/components/SecurableObjectFormFields.js:
##########
@@ -718,12 +758,17 @@ export default function SecurableObjectFormFields({
fieldName, fieldKey, metalak
</Select>
Review Comment:
If the user changes the catalog while a schema search debounce is pending,
the scheduled search can still run and overwrite the schemas for the newly
selected catalog. Clear any pending schema-search timeout when catalog changes
to prevent stale results.
##########
web-v2/web/src/components/SecurableObjectFormFields.js:
##########
@@ -631,13 +667,17 @@ export default function SecurableObjectFormFields({
fieldName, fieldKey, metalak
</Select>
<Select
showSearch
- filterOption={(input, option) =>
-
String(option.label).toLowerCase().includes(String(input).toLowerCase())
- }
+ filterOption={false}
placeholder={'Please search or select schema name'}
loading={schemasLoading}
value={localSchemaVal}
- onSearch={() => {}}
+ onSearch={val => {
+ if (val) {
+ debouncedSearchSchemas(localCatalogVal, val)
+ } else if (localCatalogVal) {
+ loadSchemasForCatalog(localCatalogVal)
+ }
+ }}
Review Comment:
When the schema search box is cleared, a previously scheduled debounced
search can still fire and overwrite the full schema list loaded by
`loadSchemasForCatalog`. Clear any pending schema-search timeout before
reloading the full list.
--
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]