-
Notifications
You must be signed in to change notification settings - Fork 67
editable fields #3
Comments
Hello, there is already something in place that might help you: each key and primitive property renders a hidden input that could become visible once that block is focused – much like it's done in Chrome DevTools: To enable that, add the following to your CSS: .json-inspector__selection {
display: block;
position: absolute;
top: 0;
left: -3px;
right: 0;
z-index: 1;
padding: 0 3px;
font: 11px/1 Menlo, Consolas, monospace;
outline: none;
border: none;
opacity: 0;
box-shadow: 3px 3px 4px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(0, 0, 0, 0.3);
color: #222;
}
.json-inspector__selection:focus {
opacity: 1;
} The component is located in |
I'd really like to have the same behavior as the dev tools, esp. the response to tabs. I'm certain, you're familiar, but just to be explicit and on the same page:
Regarding the read / write, I think it'd be a good idea to not modify the data by default. Similar to how React handles the input values with it's controlled component concept:
You could also enable "in place" editing:
That'd copy the provided JSON object and then modify that directly. |
I agree, working tabs would be really nice, need to figure out cheaper solution to that. Also agree that component should not modify the original data itself, it's better done through intent callbacks, like // editor.js
// ...
render: function() {
var data = this._getData(); // gets either the original data or the modified one
// FIXME: Figure out a good name for the prop name, callback name and the passed component.
var inputComponent = <CustomInput onSubmit={ this._onCommit } />
return <Inspector data={data} selection={ inputComponent } />
},
_onCommit: function(keypath, changedValue) {
this._setData(
applyPatch(this._getData(), keypath, changedValue)
);
} As for naming, we can call this component |
Ok, I think I get your approach and I think that'd also enable all kinds of cool editor fields - any custom element, which is really nice. So whenever a field gets focus, this component will get rendered, receive a |
Added |
I completely overlooked the fact that I wasn't passing current keypath or any other relevant information to the interactive label. Since 682c7ed it now receives:
Hope it will help better. Released as |
How is it intended to be used in the above use case? Right now the inputs are always shown when the factory is provided. The I suppose you're aware of the fact, that you can't add any new properties to object right now, but I still wanted to mention it, just in case. :) Thanks for the work so far! |
The way I used it before was rendering an invisible, yet focusable input, and revealing it when focused. Check if it works for your case. As for adding new keys, do you want to mimic the Chrome DevTools interaction (double-click on empty area, Enter or Tab from last available field) or have explicit visual control, e.g. 'Add key' button? |
How would they gain focus? The labels wrapping the inputs are targeted at the radios and tabbing through the whole application to eventually focus one of the fields is not really all that user friendly. For adding new keys I'm fine with either. |
I have just put |
Ahhh, no - you understood perfectly, it was me who was a little bit slow. |
Hi, there was a bug when updating a property value would not rerender the corresponding node, it's fixed in 5.0.3. Just thinking that this bug could affect the feature you are working on. |
Beautiful! |
hey, thanks for developing the component :)
my app needs to to display, search and modify json object. do you have anything planned for this? if not, would you accept a proper pull request including such a feature?
The text was updated successfully, but these errors were encountered: