Skip to content
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

open actionView to appropriate location when clicking on product text fields #3015

Merged
merged 14 commits into from
Oct 7, 2017
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions imports/plugins/core/ui/client/components/textfield/textfield.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,18 @@ class TextField extends Component {
}
}

/**
* onFocus
* @summary set the state when the input is focused
* @param {Event} event Event object
* @return {void}
*/
onFocus = (event) => {
if (this.props.onFocus) {
this.props.onFocus(event, event.target.value, this.props.name);
}
}

/**
* onKeyDown
* @summary set the state when the value of the input is changed
Expand Down Expand Up @@ -104,6 +116,7 @@ class TextField extends Component {
className={`${this.props.name}-edit-input`}
onBlur={this.onBlur}
onChange={this.onChange}
onFocus={this.onFocus}
placeholder={placeholder}
ref="input"
value={this.value}
Expand Down Expand Up @@ -133,6 +146,7 @@ class TextField extends Component {
name={this.props.name}
onBlur={this.onBlur}
onChange={this.onChange}
onFocus={this.onFocus}
onKeyDown={this.onKeyDown}
placeholder={placeholder}
ref="input"
Expand Down Expand Up @@ -254,6 +268,7 @@ TextField.propTypes = {
name: PropTypes.string,
onBlur: PropTypes.func,
onChange: PropTypes.func,
onFocus: PropTypes.func,
onKeyDown: PropTypes.func,
onReturnKeyDown: PropTypes.func,
placeholder: PropTypes.string,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,7 @@ class ProductAdmin extends Component {
i18nKeyTitle="productDetailEdit.productSettings"
title="Product Settings"
onChange={this.handleFieldChange}
name={"productDetails"}
/>
<Components.CardBody expandable={true}>
<Components.Select
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import Velocity from "velocity-animate";
import "velocity-animate/velocity.ui";
import { Components, registerComponent } from "@reactioncommerce/reaction-components";

import { Reaction } from "client/api";

class ProductField extends Component {
state = {
value: this.value
Expand Down Expand Up @@ -43,6 +45,12 @@ class ProductField extends Component {
}
}

handleFocus = (event) => {
// Open actionView, if it's not open already
// Set actionView to the productDetails pane
Reaction.state.set("edit/focus", "productDetails");
}

get fieldName() {
return this.props.fieldName;
}
Expand Down Expand Up @@ -97,6 +105,7 @@ class ProductField extends Component {
multiline={this.props.multiline}
onBlur={this.handleBlur}
onChange={this.handleChange}
onFocus={this.handleFocus}
onReturnKeyDown={this.handleBlur}
value={this.state.value}
{...this.props.textFieldProps}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,9 @@ const wrapComponent = (Comp) => (
handle: handle
});

// Open actionView to productDetails panel
Reaction.state.set("edit/focus", "productDetails");

Reaction.setActionView({
i18nKeyLabel: "productDetailEdit.productSettings",
label: "Product Settings",
Expand Down