mirror of
https://github.com/usatiuk/ustk-todolist.git
synced 2025-10-28 23:57:49 +01:00
add enter handlers for edit/create list
This commit is contained in:
@@ -85,9 +85,8 @@ export function removeList() {
|
||||
if (json.success) {
|
||||
dispatch(removeListFromState(list));
|
||||
state = getState();
|
||||
const newList = state.lists.lists[Object.keys(state.lists.lists)[0]]
|
||||
? state.lists.lists[Object.keys(state.lists.lists)[0]].id
|
||||
: '';
|
||||
const lists = Object.values(state.lists.lists);
|
||||
const newList = lists.length ? lists[lists.length - 1].id : '';
|
||||
dispatch(changeList(newList));
|
||||
}
|
||||
dispatch(validateLists());
|
||||
|
||||
@@ -13,7 +13,6 @@ export default function Selector({
|
||||
creating,
|
||||
addList,
|
||||
editList,
|
||||
dirty,
|
||||
}) {
|
||||
if (creating) {
|
||||
let input = null;
|
||||
@@ -25,6 +24,11 @@ export default function Selector({
|
||||
}}
|
||||
id="input"
|
||||
type="text"
|
||||
onKeyPress={e => {
|
||||
if (e.key === 'Enter') {
|
||||
addList(input.value);
|
||||
}
|
||||
}}
|
||||
/>
|
||||
<button onClick={() => addList(input.value)}>
|
||||
<FontAwesomeIcon icon={faPlus} />
|
||||
@@ -43,6 +47,11 @@ export default function Selector({
|
||||
defaultValue={lists.lists[list].name}
|
||||
id="input"
|
||||
type="text"
|
||||
onKeyPress={e => {
|
||||
if (e.key === 'Enter') {
|
||||
editList(input.value);
|
||||
}
|
||||
}}
|
||||
/>
|
||||
<button onClick={() => editList(input.value)}>
|
||||
<FontAwesomeIcon icon={faCheck} />
|
||||
@@ -78,5 +87,4 @@ Selector.propTypes = {
|
||||
editList: PropTypes.func.isRequired,
|
||||
addList: PropTypes.func.isRequired,
|
||||
lists: PropTypes.object.isRequired,
|
||||
dirty: PropTypes.bool.isRequired,
|
||||
};
|
||||
|
||||
@@ -69,7 +69,10 @@ class Todo extends React.Component {
|
||||
/>
|
||||
</div>
|
||||
) : (
|
||||
<button className={todoClasses.join(' ')} onClick={this.props.toggleTodo}>
|
||||
<button
|
||||
className={todoClasses.join(' ')}
|
||||
onClick={this.state.hover && this.props.toggleTodo}
|
||||
>
|
||||
{this.props.todo.text}
|
||||
</button>
|
||||
);
|
||||
|
||||
@@ -12,7 +12,6 @@ function mapStateToProps(state) {
|
||||
list: state.lists.list,
|
||||
editing,
|
||||
creating: state.lists.creating,
|
||||
dirty: state.lists.dirty,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user