Always enable Save button on comment editors

WebKit (so Safari and Google Chrome) has a bug where the application
can't receive notice of the backspace keyboard event when the user
has selected a word and deletes an entire word in one keystroke.  We
wanted that event so we could enable the Save button, but since we
can't receive it we just leave the Save button enabled all of the time
in case the user has made any modifications.

Bug: GERRIT-244
Signed-off-by: Shawn O. Pearce <sop@google.com>
This commit is contained in:
Shawn O. Pearce
2009-07-18 11:35:12 -07:00
parent aaa09300d8
commit f741229f50

View File

@@ -16,7 +16,6 @@ package com.google.gerrit.client.patches;
import com.google.gerrit.client.reviewdb.PatchLineComment;
import com.google.gerrit.client.rpc.GerritCallback;
import com.google.gerrit.client.ui.TextSaveButtonListener;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.event.dom.client.KeyCodes;
@@ -140,8 +139,6 @@ class CommentEditorPanel extends Composite implements ClickHandler {
save = new Button();
save.setText(PatchUtil.C.buttonSave());
save.addClickHandler(this);
new TextSaveButtonListener(text, save);
save.setEnabled(false);
buttons.add(save);
cancel = new Button();
@@ -252,6 +249,7 @@ class CommentEditorPanel extends Composite implements ClickHandler {
}
comment = result;
text.setReadOnly(false);
save.setEnabled(true);
cancel.setEnabled(true);
discard.setEnabled(true);
render();
@@ -285,7 +283,6 @@ class CommentEditorPanel extends Composite implements ClickHandler {
return;
}
final boolean saveOn = save.isEnabled();
text.setReadOnly(true);
save.setEnabled(false);
cancel.setEnabled(false);
@@ -301,7 +298,7 @@ class CommentEditorPanel extends Composite implements ClickHandler {
@Override
public void onFailure(final Throwable caught) {
text.setReadOnly(false);
save.setEnabled(saveOn);
save.setEnabled(true);
cancel.setEnabled(true);
discard.setEnabled(true);
super.onFailure(caught);