react-crudeditor icon indicating copy to clipboard operation
react-crudeditor copied to clipboard

Proposal: uiConfig 2-way communication logic

Open estambakio-sc opened this issue 8 years ago • 0 comments

In order to give users a possibility to customize UI we introduced a uiConfig prop for crud editor (usage example).

While it's fine as it is for most cases, it's not sufficient when editor can change its UI state from within. For example, we can wire up a prop to set initial show/hide state for the search form, but when you change it by clicking an arrow on Search view in a header, incoming props mismatch the inner state. If a visitor navigates away and back to the editor, search form will be visible or hidden based on the initial prop value, forgotten about the last state when a visitor left off.

In order to handle such cases we can introduce a callback function inside uiConfig:

uiConfig={{
  headerLevel: 2,
  hideSearchForm: true,
  ...otherProps,
  onChange: ({
    propName: <string, for ex. 'hideSearchForm'>,
    newValue: <any, corresponding prop value inside the editor>
  }) => {
    ...whatever it is the outer App wants to do when it receives events with updated values
  }
}}

The idea is much like the one behind onTransition but handles runtime changes of the uiConfig props.

TBD: @amourzenkov-sc

estambakio-sc avatar Nov 30 '17 07:11 estambakio-sc