-
-
Notifications
You must be signed in to change notification settings - Fork 229
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
✨ Add link/unlink button for the subtitle in the chart admin #2760
Conversation
Hi @danyx23 thanks for doing this, I think it works as expected. I've tested its functionality with Also, as a side note, I've realised that the ETL So overall I think this PR does the right thing, and it fixes the issue of not having empty subtitles, thanks! |
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.
I can't follow the details of the code, but the functionality is the expected one.
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.
Looks good to me! I played around with it a bit and the functionality feels natural to me.
A more general note: If we start linking more and more fields to metadata, I'm wondering if it would be valuable to authors if we mentioned where the default values are coming from?
adminSiteClient/Forms.tsx
Outdated
/> | ||
<div className="input-group"> | ||
<textarea | ||
className="form-control custom-control" |
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.
Any particular reason you added the custom-control
class? I'm asking because it adds a little too much padding on the left and puts the text area in the foreground such that the button's left border is hidden.
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.
Good point, this might well be unnecessary. I was looking through the bootstrap docs and they didn't have an example of a button with a textarea and the example use that I found had the custom-control class which is probably redundant. Will see if we can remove this.
@@ -785,6 +819,75 @@ export class BindAutoString< | |||
} | |||
} | |||
|
|||
/** This text field is for cases where you want to have a text field or text area |
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.
I don't think I fully understand how BindAutoStringExt
is different from BindAutoString
. Shouldn't something like
<BindAutoString
field="subtitle"
store={grapher}
auto={grapher.currentSubtitle}
/>
do exactly what we need (assuming BindAutoString
supports text areas)?
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.
I tried this first but it was annoying to align the uses that were a bit different in different cases. Also, the BindAutoString class is typed with a bunch of any
's because the property access can't be typed precisely enough. The approach with getter and setter functions is trivial to type precisely so I prefer that solution.
Do you think I should rewrite the other uses and remove BindAutoString?
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.
Nah, no need to rewrite. I was just wondering if I was missing something essential here :)
@pabloarosado thanks for testing it! Interesting find about the indicator grapher config subtitle being used initially but not anymore later on. I think this is ok-ish for now but let's keep looking out for weird cases like this. In general I think our appetite to improving this is high, it's just a question of how early we want to chip away further vs. plan things a bit more coherently for next year. @sophiamersmann thanks a lot for your review! I agree, making it clearer where the defaults are coming from will be very useful. When we start using defaults for all properties in the charts admin it might be quite nice to be able to switch between 3 different views: the merged chart configs, only the ETL one and only the "chart" one. Definitely something to think about more :) |
67d90b4
to
daff095
Compare
With descriptionShort being used as a fallback for the subtitle in a chart we now have seen some unfortunate cases that made it necessary to be able to control if the fallback should be used or not.
The reason why this is necessary is that some old charts do not have a subtitle. If we now update the indicator to have a descriptionShort then all of a sudden this desriptionShort would be used as subtitle which is maybe not what we want.
To fix this, the PR adds a link button to the subtitle text field in the chart admin. If a custom text is set then the button shows as "unlinked". If you click it the button links and you get whatever default the fallback chain provides (i.e. descriptionShort or no subtitle).
For cases where there is currently no subtitle and you want to makes sure it stays this way, set the subtitle to linked but the subtitle text to empty.
An easy way to test this is by looking at this chart that uses the Dummy indicator (which has descriptionShort).
@pabloarosado can you test this and see if it behaves the way you would expect?