-
Notifications
You must be signed in to change notification settings - Fork 29
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
Reset optional file field #156
Comments
Hi @macfire In fact I like the idea of adding a 'reset' button of some kind when the file or folder type is indicated as 'optional'. The workaround you try is not that ideal indeed as there's no way to say to the UI to refresh at any point. The preferences window will just render the initial preferences and refresh while the user interacts with the preference window. If you'd like to contribute to this repo, please go ahead and open a PR with the above suggested solution :) |
Definitely support this idea, I currently have to add extra preferences to "Enable" a customization because there's no simple way to reset (especially the color-picker). I also had to restrict the keys "Escape"/"Backspace"/"delete" from the accelerator to be used to reset the input. After this is added it may be worth going back to allow those keys to be used normally |
Good point. We should review the different types and check if an 'optional' boolean is applicable per type. My proposal:
|
I'm going to make an argument for It's not necessarily an issue as the program can offer a "not selected" option (at least for For my app, I have settings that are not applicable until the user has set them, so this would be helpful in those scenarios. |
I've cloned this repository, and updated the file field with a reset button as follows. In components/fields/file/index.jsx constructor(props) {
super(props);
this.choose = this.choose.bind(this);
this.reset = this.reset.bind(this);
}
render() {
....
const btResetLabel = 'Reset';
return (
<div className={`field field-file key-${this.field.key}`}>
<div className="field-label" aria-label={ label }>{label}</div>
<div className="value" onClick={this.choose}>
{multiSelections ? 'Files' : 'File'}:
{
value
? (
multiSelections || value.length > 1
? <ul>{value.map((v, i) => <li key={i}>{v}</li>)}</ul>
: value[0]
)
: 'None'
}
</div>
<button className="bt" onClick={this.choose} aria-label={ btLabel }>
{btLabel}
</button>
<button className="bt bt-reset" onClick={this.reset} aria-label={ btResetLabel }>
{btResetLabel}
</button>
{help && <span className="help">{help}</span>}
</div>
);
}
// new method
reset() {
this.onChange();
} Note: |
Hi @macfire The default variable with A few remarks I noticed already:
|
@pvrobays exactly, reset to default value if there is one, and |
Would like option to display a "reset button" on file field when input is optional.
My current implementation: Add button field after the file field, then attach click event to set file field value to null.
Example:
Issue
The preferences JSON is updated/saved correctly, and main window updates.
However, I don't know how to update the Preferences window render.
The file field still shows the previously selected file until window is closed and re-opened.
Any suggestions welcomed. Thanks.
The text was updated successfully, but these errors were encountered: