Skip to content

Conversation

dehli
Copy link
Contributor

@dehli dehli commented Oct 20, 2016

Reasons for making this change

With this change, I've added a reference to the input element in FileWidget. The reason I did this is because I've created a custom widget which is composed of a hidden FileWidget and a nice looking button (that way you don't need to have the browser styled file button).

By exposing inputRef, I can progammatiacally call the input's choose file by calling: fileWidgetRef.inputRef.click() whenever the fancy button is clicked.

I can add documentation and a playground if you'd like.

Also this library is great, thanks! 😄

Checklist

  • I'm adding or updating code
    • I've added and/or updated tests
    • I've updated docs if needed
  • I'm updating documentation
    • I've checked the rendering of the Markdown text I've added
    • If I'm adding a new section, I've updated the Table of Content
  • I'm adding a new feature
    • I've updated the playground with an example use of the feature

@leplatrem
Copy link
Contributor

leplatrem commented Oct 21, 2016

I wouldn't be against if this it really serves this use-case. Indeed, browse buttons are ugly.

@n1k0 what do you think?

Also this library is great, thanks! 😄

❤️

@n1k0
Copy link
Collaborator

n1k0 commented Oct 21, 2016

@n1k0 what do you think?

I don't have a string opinion about it, though I've read bad things about react refs in the past, while I've never used them myself.

The patch looks small and trivial enough to land it if it solves people's problems I think :)

@n1k0
Copy link
Collaborator

n1k0 commented Oct 21, 2016

Maybe adding a line or two of docs for this would be great.

@dehli
Copy link
Contributor Author

dehli commented Oct 21, 2016

Thanks! @n1k0 @leplatrem I've added some documentation to the README.md. Let me know what you think. :)

Copy link
Collaborator

@n1k0 n1k0 left a comment

Choose a reason for hiding this comment

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

Just some bikeshedding (sorry!) and we're good to go! Thanks :)

README.md Outdated
##### File widget input ref

The included `FileWidget` exposes its `<input type="file"></input>` via `inputRef`.
Copy link
Collaborator

@n1k0 n1k0 Oct 21, 2016

Choose a reason for hiding this comment

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

Nit: The included FileWidget exposes a reference to the <input type="file" /> element node as a inputRef component property.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That sounds so much better :) Thanks!

@n1k0 n1k0 merged commit c512f91 into rjsf-team:master Oct 21, 2016
@n1k0
Copy link
Collaborator

n1k0 commented Oct 21, 2016

Thank you! This will be released anytime soon next week :)

n1k0 added a commit that referenced this pull request Nov 9, 2016
This release has been made possible by the combined work of @olzraiti, @maartenth, @vinhlh, @tiemevanveen , @dehli, @enjoylife, @PabloEn, @israelshirk, @sjhewitt and @rom10. Thank you folks!

Breaking changes
----------------

Support for passing `DescriptionField`, `TitleField` and `SchemaField` as `Form` props as been dropped in this release. You now have to always pass them through the `fields` prop.

Deprecations
------------

* Leverage `ui:options` everywhere (fix #370) (#378)

There's now a unique recommended way to specify options for widgets in uiSchema, which is the `ui:options` directive. Previous ways are still supported, but you'll get a warning in the console if you use them.

New features
------------

* Allow overriding the default fields/widgets (#371)
* Pass data to `FieldTemplate` as strings instead of as React components (#341)
* Pass `schema` & `uiSchema` to the field template component (#379)
* Add `ui:order` wildcard feature and improve error messages (#368)
* Add support for widget autofocus (#288)
* Array field optional sortability (#345)
* Radio widget support for integers and numbers (#325)
* Add support for inline radios and checkboxes. (fix #346) (#348)
* Added ref to `FileWidget`. (#355)
* Added `removable` and `addable` options for array items (#373)
* Enable Windows development (#320)

Enhancements and bugfixes
-------------------------

* Fix `minimum/maximum==0` for `UpDownWidget` and `RangeWidget` (#344)
* Handle numbers requiring trailing zeros with more grace (#334)
* Pass empty title to `TitleField` instead of name (#311)
* `asNumber`: return `undefined` when value is empty string (#369)
* Use [glyphicons](http://getbootstrap.com/components/#glyphicons) for buttons by default. (fix #337) (#375)
* Support old versions of React (#312)
@n1k0
Copy link
Collaborator

n1k0 commented Nov 9, 2016

Released in v0.41.0.

@jariwalabhavesh
Copy link

jariwalabhavesh commented Oct 30, 2017

@dehli: @n1k0
Can you please provide example how can i access refs in form that we provide in file widget.?

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.

4 participants