SideBySide2: Edit during single click of short drafts
When a draft is shorter than 70 characters it auto-collapses after save to minimize the vertical screen space consumed by the widget. If a user clicks on this draft, they are most likely doing so to make a quick modification. Save a few actions by starting edit immediately on single click. The user can cancel or press Escape to undo the edit and have the comment collapse again. Change-Id: I32fd65c5b5bd0ed06797ef5fb675a48f8161add4
This commit is contained in:
@@ -63,6 +63,7 @@ class DraftBox extends CommentBox {
|
|||||||
private CommentInfo comment;
|
private CommentInfo comment;
|
||||||
private PublishedBox replyToBox;
|
private PublishedBox replyToBox;
|
||||||
private Timer expandTimer;
|
private Timer expandTimer;
|
||||||
|
private boolean autoClosed;
|
||||||
|
|
||||||
@UiField Widget header;
|
@UiField Widget header;
|
||||||
@UiField Element summary;
|
@UiField Element summary;
|
||||||
@@ -105,7 +106,12 @@ class DraftBox extends CommentBox {
|
|||||||
@Override
|
@Override
|
||||||
public void onClick(ClickEvent event) {
|
public void onClick(ClickEvent event) {
|
||||||
if (!isEdit()) {
|
if (!isEdit()) {
|
||||||
setOpen(!isOpen());
|
if (autoClosed && !isOpen()) {
|
||||||
|
setOpen(true);
|
||||||
|
setEdit(true);
|
||||||
|
} else {
|
||||||
|
setOpen(!isOpen());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, ClickEvent.getType());
|
}, ClickEvent.getType());
|
||||||
@@ -129,6 +135,7 @@ class DraftBox extends CommentBox {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void set(CommentInfo info) {
|
private void set(CommentInfo info) {
|
||||||
|
autoClosed = info.message() != null && info.message().length() < 70;
|
||||||
date.setInnerText(FormatUtil.shortFormatDayTime(info.updated()));
|
date.setInnerText(FormatUtil.shortFormatDayTime(info.updated()));
|
||||||
if (info.message() != null) {
|
if (info.message() != null) {
|
||||||
String msg = info.message().trim();
|
String msg = info.message().trim();
|
||||||
@@ -275,11 +282,9 @@ class DraftBox extends CommentBox {
|
|||||||
public void onSuccess(CommentInfo result) {
|
public void onSuccess(CommentInfo result) {
|
||||||
enableEdit(true);
|
enableEdit(true);
|
||||||
set(result);
|
set(result);
|
||||||
if (result.message().length() < 70) {
|
setEdit(false);
|
||||||
UIObject.setVisible(p_edit, false);
|
if (autoClosed) {
|
||||||
setOpen(false);
|
setOpen(false);
|
||||||
} else {
|
|
||||||
setEdit(false);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -311,6 +316,9 @@ class DraftBox extends CommentBox {
|
|||||||
removeUI();
|
removeUI();
|
||||||
} else {
|
} else {
|
||||||
setEdit(false);
|
setEdit(false);
|
||||||
|
if (autoClosed) {
|
||||||
|
setOpen(false);
|
||||||
|
}
|
||||||
getCm().focus();
|
getCm().focus();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -349,6 +357,9 @@ class DraftBox extends CommentBox {
|
|||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
setEdit(false);
|
setEdit(false);
|
||||||
|
if (autoClosed) {
|
||||||
|
setOpen(false);
|
||||||
|
}
|
||||||
getCm().focus();
|
getCm().focus();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user