Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add other as an option to specific fields #3031

Merged
merged 5 commits into from Mar 17, 2023

Conversation

neatbyte-vnobis
Copy link
Collaborator

Changes

Implement issue "Forms: Add “other” as an option to specific fields"

How Has This Been Tested?

Manual

Documentation

None

@SvenAlHamad
Copy link
Contributor

This works well, but I would just suggest one improvement. When we have the "other" option active, can we hide the other input and only show it when the user clicks on the other option in the form and then we display the input and automatically focus on it.

@adrians5j adrians5j self-assigned this Feb 21, 2023
@SvenAlHamad
Copy link
Contributor

SvenAlHamad commented Feb 21, 2023

I'm good with this implementation. @adrians5j or @Pavel910 this is ready for a code review.

@adrians5j
Copy link
Member

Checking.

Copy link
Member

@adrians5j adrians5j left a comment

Choose a reason for hiding this comment

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

Although the feature doesn't look like it, the PR is not trivial. A lot of stuff to go through and wrap my head around.

Let's start with a couple of comments I left and we'll do additional iterations if needed.

BTW something I also noticed while giving this new feature a try. This "Allow other" text should be a bit smaller:

image

name={`${fieldId}Other`}
id={`${fieldId}Other`}
ref={otherInputRef}
disabled={!checked({ option: otherOption, value })}
Copy link
Member

Choose a reason for hiding this comment

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

Couldn't we simply render or not render the OtherInput, depending on the checked call result? A bit confused why we're using disabled here and then hiding the field if it's true (via above CSS).

change({ option: otherOption, value, onChange });
if (e.target.checked && otherInputRef.current) {
otherInputRef.current.disabled = false;
otherInputRef.current.focus();
Copy link
Member

Choose a reason for hiding this comment

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

Would the following eliminate all these lines of code?
https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/autofocus

Let's try that, but I believe my previous comment would also need to be applied in order for the autofocus to work.

}
};
},
renderSettings({ form }) {
return (
<Grid>
<Cell span={12}>
<OptionsList form={form} multiple />
<OptionsList form={form} multiple otherOptionSwitch />
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
<OptionsList form={form} multiple otherOptionSwitch />
<OptionsList form={form} multiple otherOption />

Let's rename to otherOption.

@neatbyte-vnobis
Copy link
Collaborator Author

@adrians5j
Comments above are fixed, please take a look.

@neatbyte-vnobis
Copy link
Collaborator Author

@adrians5j
please take a look on this PR
I hope we can merge it (as previous comments are fixed)

Copy link
Member

@adrians5j adrians5j left a comment

Choose a reason for hiding this comment

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

Nice, thanks @neatbyte-vnobis !

@adrians5j adrians5j added this to the 5.35.0 milestone Mar 17, 2023
@adrians5j adrians5j merged commit d394754 into next Mar 17, 2023
52 checks passed
@neatbyte-vnobis neatbyte-vnobis deleted the form-builder-other-radio-and-checkbox-options branch March 28, 2023 15:39
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.

None yet

3 participants