-
Notifications
You must be signed in to change notification settings - Fork 115
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
NEW Edit tab click changes tab state #428
NEW Edit tab click changes tab state #428
Conversation
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.
The code looks good, although it could use a run over with a linter - there are a few extremely minor formatting issues around the place (to do with white space).
I can't help but think that this approach is a bad form of coupling though - e.g. There's no away an Element should be concerned with which tab is currently active - and even if it should be, to which Tabs component does it refer?
I feel like this is caught between a rock and a hard place in that the majority of controls we should like to affect are nested within the scaffolding component (FormBuilderLoader
) - but as we discussed in person this PR is good to get a discussion going around the approach.
Perhaps there is a way to leverage the SilverStripe javascript Injector
to wrap a higher order component around the Tabs
component in this context, hooking it up to a redux reducer we control (as opposed to reduxform) in order to handle receiving the active tab value from an event dispatched directly to it (from wherever else that may be in hierarchy - where at the moment it's very coupled to the tree hierarchy presented in this PR).
I don't block this from a merge though, it can meet MVP and be followed up later in dealing with technical debt.
What are everyone else's thoughts?
/** | ||
* Set the active tab | ||
* | ||
* @param activeTab |
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.
Missing type
@@ -48,7 +48,7 @@ class ElementList extends Component { | |||
} | |||
|
|||
return blocks.map((element) => ( | |||
<div> | |||
<div key={element.ID}> |
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'm curious about whether giving it the same key as its child element might cause rendering issues... I don't know enough about how this works in React though
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.
In this case I think we can remove the key from the child component. I'm not 100% on this either but I'm pretty sure it's only used for the top level dom elements within a loop.
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.
Actually can we just remove that div? It doesn't seem to serve any purpose?
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.
"Adjacent JSX elements must be wrapped in an enclosing tag" 😉
|
||
const sectionKey = 'DNADesign\\Elemental\\Controllers\\ElementalAreaController'; | ||
const section = Config.getSection(sectionKey); | ||
const formNameTemplate = section.form.elementForm.formNameTemplate; |
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.
You can use loadElementSchemaValue('formNameTemplate')
for this (see client/src/state/editor/loadElementSchemaValue.js
)
|
||
/** | ||
* Update the active tab on tab actions menu button click event. | ||
* @param event onChangeEvent from a input field. |
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.
Missing prevProps
declaration
646328f
to
88a491a
Compare
6d68844
to
09b2f63
Compare
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.
Looking really awesome. Been pretty nit-picky - I just want to know if we can avoid adding redux-form as a dependancy.
onClick={(event) => event.stopPropagation() | ||
} | ||
> | ||
<ElementActionsComponent {...this.props} /></div> |
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.
What's this wrapping div
doing? The </div>
should be a on a new line.
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.
It allows to ignore the button press on the divider tab item.
// {@see Tabs.getDefaultActiveKey} | ||
const filterFieldsForTabs = (field) => field.component === 'Tabs'; | ||
const defaultValue = state.form.formSchemas[elementFormSchema].schema.fields | ||
.filter(filterFieldsForTabs)[0].children[0].name; |
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.
You could use find
instead of filter
here. Also, it'd probably be good to defensively program in for the possibility there's no tabs - although admittedly there's probably some work to do elsewhere for this...
@@ -48,7 +48,7 @@ class ElementList extends Component { | |||
} | |||
|
|||
return blocks.map((element) => ( | |||
<div> | |||
<div key={element.ID}> |
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.
In this case I think we can remove the key from the child component. I'm not 100% on this either but I'm pretty sure it's only used for the top level dom elements within a loop.
09b2f63
to
552e989
Compare
552e989
to
5632e26
Compare
…her than storing it in local state.
5632e26
to
b9898ef
Compare
Related issue:
Related PRs:
This is work in progress for the above issue. The related PRs connect
Tabs
to the redux-form store.I would like some initial feedback on the approach taken. Since we are dispatching an action I am not sure if bubbling up the edit tab click from
ElementActions
toElement
, saving the active tab inElement
's local state and passing it down as a prop toInlineEditForm
is the most elegant solution.Outstanding work includes styling of the selected edit tab and cursor, as well as expanding the form on edit tab click.