-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Made it so that nullable radio defaults correctly (fix #545) #589
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
Made it so that nullable radio defaults correctly (fix #545) #589
Conversation
… enter something it selects the left radio button.
|
Review app available at: https://hge-ci-pull-589.herokuapp.com |
|
LGTM. @praveenweb can you please take a look? |
|
@zacbraddy - Hey, just verified your implementation in the above sample heroku app. But doesn't seem like it has been fixed. When i try to type in a text field which is nullable, the left radio has to be selected (typical onChange handler). But it doesn't get selected as expected. Can you recheck? |
|
@zacbraddy - Just to clarify, your implementation works only for text fields. The expectation is that it should work for all types of fields, like integer, timestamp and boolean fields etc. Let me know if you want to proceed working for that implementation :) |
|
Hi there @praveenweb Yep, just a misunderstanding on my part mate. I thought this was only something you wanted done on text fields. That's fine I'll open up the code again tonight when I get home from work and make this functionality available for all nullable types and then push the change to my PR. Hang tight ;) |
insert item components
|
Ok mate, I've included that functionality that I added to text nullable types to all nullable types. In doing so I also went ahead and cleaned up a little bit of that component as there were some functions that were only being used in zombie code or not at all in the project. Once I'd cleaned all those up I found that there wasn't as much of a need for the giant if-then-else chain we had. I know it looks like I've changed a lot of code but if you look at the diff type by type and compare to my code you should find that the only significant differences are that I've added the |
|
Review app available at: https://hge-ci-pull-589.herokuapp.com |
|
@zacbraddy Thanks for your contribution ✨. Works as expected for fields marked Do you think it will be easy to add the same behaviour to @praveenweb What do you think? I know it's out of scope for the current issue. But would be nice to have. |
|
@zacbraddy - Thanks. The code refactor looks nice. The giant if-else being rewritten to switch case was neat. The unused code you mentioned was used before when there was a Rich Text Editor functionality for text fields. We had commented out that now, except for this function. As @shahidhk mentioned in the above comment, can you also add the same behaviour if the field is |
|
@praveenweb @shahidhk Yeah guys I can absolutely add something like that. The change isn't massive, however, it's more the "How things should work?" that makes doing it complex. Am I correct in saying that a field can be nullable as well as having a default. If this is the case which should take precedence when the text changes. The questions that need answering are below. I've guessed at the ones I could I've left the ones I'm unsure of for you to answer. A field is not nullable or defaulted A field is nullable, but not defaulted or auto incremented
A field is nullable, and auto incremented (implicit default implied here)
A field is nullable, but not auto incremented and defaulted
|
Yes this scenario seems to be possible when you want a field to assume default value and accept
Now if at all user wants to have control on the radio button selection he can use arrow keys to navigate between radio buttons.
|
|
There you go, as requested 😃 |
|
Awesome @zacbraddy 😎 Looks like some tests are failing for console. @praveenweb @karthikvt26 Can you help out @zacbraddy to fix the tests? |
|
Oh bugger, it's cool I'll look into the failing tests and see if I can fix them. I'm going on holiday for a long weekend this weekend so I won't be able to look at them until next week. But if there's no urgency on this then I'm happy to take a look into fixing these when I get back. |
|
@wawhal Can you quickly check why the tests are failing here and comment with a possible fix? |
|
Review app available at: https://hge-ci-pull-589.herokuapp.com |
| onClick: clicker, | ||
| onChange: e => { | ||
| const textValue = e.target.value; | ||
| if (isNullable && !isAutoIncrement) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also make the radio checked, if the field has a default value. So add another condition?
|
@zacbraddy Good news, the tests have been fixed. Finally we can merge this 🎉 👏 Thanks for the contribution 🙏. You'll receive a comment from our bot to fill up your address etc. so that we can send some goodies. Don't forget to fill that when you're back from your vacation. 😄 |
shahidhk
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
|
Review app https://hge-ci-pull-589.herokuapp.com is deleted |
|
Beep boop! 🤖 Whoa! 🎉 🎉 💃 Awesome work @zacbraddy! 💪 🏆 All of us at Hasura ❤️ what you did. We would love to send you some swag! 👕 Please allow us to do so by filling this form. If you have any questions, ask us on our Discord & Twitter! Thanks again 🤗 |
|
Ah just got back from holiday, sorry to leave you with the tests but thanks for doing that for me @shahidhk was fun working with you guys, you might see me again. Cheers! |
|
You're always welcome! |
<!-- Thank you for submitting this PR! :) --> ## Description This adds the smallest possible changes to allow the use of different options when resolving metadata. The concrete idea is this: - each crate (`metadata-resolve`, `schema` etc) will have a type for their flags (if any), but don't care where they come from - when we need to expose these experimental features through the engine (ie, to test requests in e2e tests or something), the engine will parse an env var such as `EXPERIMENTAL_FEATURES=allow_boolean_expression_types` and then use it to construct `MetadataResolveFlags`, `SchemaFlags`, etc. Functional no-op. V3_GIT_ORIGIN_REV_ID: 64ac66569f4e31829a9117c64d2e0e265d7a7303
Description
Made it so that when you focus the text input for a text field that is nullable then if the value in the text field is
undefined,null, or an empty string then the null radio box for that field with be checked.Also whilst typing in the text input of a nullable text field if you add characters, thus making the value not an empty string, then the radio to the left of the field is checked and the null radio is unchecked. If you then remove all characters leaving an empty string the radio to the left is unchecked and the null radio is checked.
The radio buttons themselves can be changed after having entered or removed a value in the text input but the behaviour above allows for the UI to choose sensible defaults for the user.
What component does this PR affect?
Requires changes from other components? If yes, please mark the components:
Type
Checklist: