Skip to content

[BUGFIX] Fix variable editing panel's custom all value text field to handle empty string#64

Open
zhuje wants to merge 4 commits intomainfrom
ou1159-custom-all-varaible
Open

[BUGFIX] Fix variable editing panel's custom all value text field to handle empty string#64
zhuje wants to merge 4 commits intomainfrom
ou1159-custom-all-varaible

Conversation

@zhuje
Copy link

@zhuje zhuje commented Feb 18, 2026

Description

Fix the editing variable panel so that the custom all value text field can handle an empty string. Previously, if you tried to delete the current string, the empty string would trigger a hook to repopulate the text field with the previous value.

Screenshots

BEFORE
https://github.com/user-attachments/assets/6eb92fc0-cd22-417c-8fea-e42b34e41fa8

AFTER
https://github.com/user-attachments/assets/c469a264-726a-4035-8bef-2e8583274e3a

Checklist

  • Pull request has a descriptive title and context useful to a reviewer.
  • Pull request title follows the [<catalog_entry>] <commit message> naming convention using one of the
    following catalog_entry values: FEATURE, ENHANCEMENT, BUGFIX, BREAKINGCHANGE, DOC,IGNORE.
  • All commits have DCO signoffs.

UI Changes

  • Changes that impact the UI include screenshots and/or screencasts of the relevant changes.
  • Code follows the UI guidelines.
  • E2E tests are stable and unlikely to be flaky.
    See e2e docs for more details. Common issues include:
    • Is the data inconsistent? You need to mock API requests.
    • Does the time change? You need to use consistent time values or mock time utilities.
    • Does it have loading states? You need to wait for loading to complete.

…dle empty string

Signed-off-by: Jenny Zhu <jenny.a.zhu@gmail.com>
@zhuje zhuje requested a review from a team as a code owner February 18, 2026 23:17
@zhuje zhuje changed the title [BUGFIX] fix variable editing panel > custom all value > text field to handle empty string [BUGFIX] Fix variable editing panel's custom all value text field to handle empty string Feb 18, 2026
@shahrokni shahrokni self-requested a review February 19, 2026 09:01
} else {
field.onChange(event);
}
field.onChange(event.target.value);
Copy link
Member

Choose a reason for hiding this comment

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

We need something on UI side for defining custom all value to undefined then.

A switch?
If enabled: show textfield and handle empty string
If disabled: undefined

Copy link
Member

Choose a reason for hiding this comment

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

Because I am pretty sure some datasources have different behaviors, if the value is empty or undefined

Copy link
Author

@zhuje zhuje Feb 22, 2026

Choose a reason for hiding this comment

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

I pushed another commit to handle the case _allAllValue is disabled then the customAllValue should be undefined.

if (!_allowAllValue && values.spec.customAllValue !== undefined) {
    form.setValue('spec.customAllValue', undefined);
  }

Copy link
Member

@Gladorme Gladorme Feb 23, 2026

Choose a reason for hiding this comment

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

To me we should handle the case where: _allowAllValue is true and customAllValue can be undefined or empty from the UI too

Copy link
Author

Choose a reason for hiding this comment

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

To me we should handle the case where: _allowAllValue is true and customAllValue can be undefined or empty from the UI too

I took another approach with useState hooks to try to synchronize what the form displays with the value of customAllValue, which was the root of the issue. Now it should handle the case where "_allowAllValue is true and customAllValue can be undefined or empty from the UI too".

Screen.Recording.2026-02-23.at.4.45.12.PM.mov

…dle empty string and undefined

Signed-off-by: Jenny Zhu <jenny.a.zhu@gmail.com>
Signed-off-by: Jenny Zhu <jenny.a.zhu@gmail.com>
onChange={(event) => {
const newValue = event.target.value;
setCustomAllDisplayValue(newValue);
if (newValue === '') {
Copy link
Member

@Gladorme Gladorme Feb 24, 2026

Choose a reason for hiding this comment

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

Now that we can set undefined with reset button, I would remove this check for allowing empty string to be set by UI users

Copy link
Author

Choose a reason for hiding this comment

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

Updated to the Switch approach.

const [customAllDisplayValue, setCustomAllDisplayValue] = useState(_customAllValue ?? '');
const [isCustomAllReset, setIsCustomAllReset] = useState(false);

useEffect(() => {
Copy link
Member

@Gladorme Gladorme Feb 24, 2026

Choose a reason for hiding this comment

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

Arf, not fan of this useEffect, that why I think using a Switch component would be simpler, for enabling or not custom all value.

If switch is enable => show text field and default value is empty string.
If false => textfield hidden and value is undefined

Copy link
Author

@zhuje zhuje Feb 24, 2026

Choose a reason for hiding this comment

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

True, Switch is probably the simpler approach. Push another commit to update it to the Switch.

Screen.Recording.2026-02-24.at.4.46.26.PM.mov

Copy link
Member

Choose a reason for hiding this comment

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

Looks better to me, I think useEffect can be removed, no? 🤔

…witch

Signed-off-by: Jenny Zhu <jenny.a.zhu@gmail.com>
const [customAllDisplayValue, setCustomAllDisplayValue] = useState(_customAllValue ?? '');
const [isCustomAllReset, setIsCustomAllReset] = useState(false);

useEffect(() => {
Copy link
Member

Choose a reason for hiding this comment

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

Looks better to me, I think useEffect can be removed, no? 🤔

onChange={(event) => {
if (action === 'read') return;
const isEnabled = event.target.checked;
setUseCustomAllValue(isEnabled);
Copy link
Member

Choose a reason for hiding this comment

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

We can remove the negation here

Suggested change
setUseCustomAllValue(isEnabled);
if (isEnabled) {
form.setValue('spec.customAllValue', '');
} else {
form.setValue('spec.customAllValue', undefined);
}

<Typography variant="caption" sx={{ mt: -0.5 }}>
Enable to set a custom value when &quot;All&quot; is selected
</Typography>
{useCustomAllValue && (
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
{useCustomAllValue && (
{_customAllValue !== undefined && (

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants