Skip to content

Revert removal of label text inference and allow nil#1047

Merged
paulcsmith merged 2 commits intomasterfrom
pcs/nil-label-text
Mar 14, 2020
Merged

Revert removal of label text inference and allow nil#1047
paulcsmith merged 2 commits intomasterfrom
pcs/nil-label-text

Conversation

@paulcsmith
Copy link
Member

#1028 (comment)

Actually I may just be overthinking this. Lucky wants to avoid bugs,
but also be practical. Sometimes nils can sneak in when you don't expect
it...but maybe label_text is not one of those places. I have a hard time
seeing a use case where someone is conditionally generating a label and
it might accidentally be nil. I think of all the apps I've ever written
I've never accidentally set label text to nil.

So I think what I'll do is make the label text String?. So that if you
pass nil to text it will infer the label name like it does now when you
leave the arg off completely. That way we can still keep the component
flexible by allowing String? but we also keep label_for flexible. I'll
go ahead and make that change now. This also means existing apps will
still work when you upgrade and this will no longer be a breaking change
👍

#1028 (comment)

> Actually I may have overthought this. Lucky wants to avoid bugs,
but also be practical. Sometimes nils can sneak in when you don't expect
it...but maybe label_text is not one of those places. I have a hard time
seeing a use case where someone is conditionally generating a label and
it might accidentally be nil. I think of all the apps I've ever written
I've never accidentally set label text to nil.

> So I think what I'll do is make the label text String?. So that if you
pass nil to text it will infer the label name like it does now when you
leave the arg off completely. That way we can still keep the component
flexible by allowing String? but we also keep label_for flexible. I'll
go ahead and make that change now. This also means existing apps will
still work when you upgrade and this will no longer be a breaking change
👍
@paulcsmith
Copy link
Member Author

Thanks for your feedback on the issue @wontruefree. I think this should be more flexible than my previous solution and will make writing Field components a lot simpler

@paulcsmith paulcsmith merged commit 443b17f into master Mar 14, 2020
@paulcsmith paulcsmith deleted the pcs/nil-label-text branch March 14, 2020 15:37
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.

1 participant