Skip to content

Firefly-2087: Refactor SuggestBoxInputField to Use a Functional Component - #2004

Open
aventura121 wants to merge 9 commits into
devfrom
FIREFLY-2087-use-joy-autocomplete-all
Open

Firefly-2087: Refactor SuggestBoxInputField to Use a Functional Component#2004
aventura121 wants to merge 9 commits into
devfrom
FIREFLY-2087-use-joy-autocomplete-all

Conversation

@aventura121

@aventura121 aventura121 commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

Firefly-2087: Refactor SuggestBoxInputField to Use a Functional Component

Description

This PR removes all of the callers to SuggestBoxInput to the Joy UI component, AutoComplete/AutoCompleteView.

Companion PR in irsa-ife (to be merged after): https://github.com/IPAC-SW/irsa-ife/pull/477

Testing

For firefly:

  1. Navigate to Tables (TAP)
  2. Input an object, e.g. m81
  3. In the table component, select the Add a Column icon (top right)
  4. Type into the UCD field
  5. We expect the dropdown to populate with suggestions, etc.
Screenshot ucd

For irsa-ife-sha (contains irsa-ife specific code changes):

  1. Navigate to the hamburger icon on the left, then select Observer. Se
  2. Enter a name in the Observer Name field, e.g. Smith
  3. We expect the dropdown to populate with suggestions, etc.
Screenshot spitzer-observer

For irsa-ife-wise:

  1. Navigate to Search by Solar System Object/Orbit
  2. Enter a name in Object Name or ID, e.g. Neptune
  3. We expect the dropdown to populate with suggestions, etc.
Screenshot wise

@aventura121 aventura121 changed the title Firefly 2087 use joy autocomplete all Firefly-2087: use joy autocomplete all Sep 4, 2026
@aventura121 aventura121 changed the title Firefly-2087: use joy autocomplete all Firefly-2087: Refactor SuggestBoxInputField to Use a Functional Component Sep 4, 2026
@aventura121 aventura121 self-assigned this Sep 4, 2026
@aventura121 aventura121 added this to the 2026.3 milestone Sep 4, 2026
@aventura121
aventura121 marked this pull request as ready for review September 4, 2026 20:51
@aventura121
aventura121 requested review from jaladh-singhal and loitly and removed request for jaladh-singhal September 4, 2026 20:52

@loitly loitly left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good work on refactoring the component. However, I have concern about the multiple validators. Could you review it and see if my concern is valid.

// pre-joy version: it tests every ';' token, not just the last one being typed.
function ucdFilterOptions(options, {inputValue}) {
// joy passes an empty inputValue on the render that opens the popup, so returning [] here would
// blank the listbox on the first keystroke

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comments should describe the code itself, not the changes made for this PR. This becomes irrelevant later when reviewing the code.

For example, the comment could be:
// UCD1+ value is a ‘;’ delimited list. The filter should return options that match any term.
// When the input is empty, return all options.

Comment on lines +116 to +121
value: any,
valid: bool,
message: string,
tooltip: string,
showWarning: bool,
validator: func, // (value) => ({valid, message}), run on every keystroke and on a selection

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Promoted to top-level props makes sense here.

Comment on lines +159 to +166
initialState: shape({
value: string,
valid: bool,
message: string,
validator: func,
nullAllowed: bool,
}),
...omit(AutoCompleteInputView.propTypes, 'value', 'valid', 'message', 'fireValueChange'),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Folding the promoted view's props back into initialState to preserve exiting API convention is fine. But, validator is missing which allow this component to have 2 separate validators. There should only be one shared by both the view and the FieldGroup controller.

Comment on lines +205 to +206
export function useAsyncOptions(getOptions, value) {
const [result, setResult]= useState({options:[], loading:false});

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

useDebounced and useAsyncOptions are great additions. They fix existing bugs. I think these functions can be reused as is or with minor tweak. If you’re interested in taking on the task, that’s something to consider.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants