Repository navigation
Conversation
|
| if (!this._enableSave && this._showDataLimit) { | ||
| return; | ||
| } |
There was a problem hiding this comment.
If a manager enters an invalid limit and then unchecks the limit checkbox, the save button stays disabled. Pressing Enter still calls _onSaveButtonTapped() because this guard also requires _showDataLimit to be true. The server then removes the key’s limit. Make the Enter guard match the save button’s disabled state.
| if (!this._enableSave && this._showDataLimit) { | |
| return; | |
| } | |
| if (!this._enableSave) { | |
| return; | |
| } |
| event.preventDefault(); | ||
| void this._onSaveButtonTapped(); |
There was a problem hiding this comment.
Repeated Enter starts extra saves
Holding Enter or pressing it again before a save finishes calls _onSaveButtonTapped() again. Neither the key handler nor the save handler marks a save as pending, so the manager sends the same server request again and can see duplicate save notifications. Ignore further Enter presses until the first save finishes.
| /** | ||
| * Enter saves (when enabled); Escape cancels — same as other Manager dialogs. | ||
| */ | ||
| private _onDialogKeydown(event: KeyboardEvent) { |
There was a problem hiding this comment.
It feels like we are reinventing the wheel here. Shouldn't the standard components have the behavior you want? Perhaps look into the dialog API instead.
(also there are the other issues from greptile)
paper-dialog already cancels on Escape (IronOverlayBehavior, no-cancel-on-esc-key is not set), so drop the custom dialog keydown handler. Handle Enter only on the data limit input, respect the save button's disabled state and ignore repeated saves while one is pending.
|
Thanks, fair point. I looked into it: So I kept a small Enter handler, but only on the limit input (same as If you'd rather move this dialog to a native |
Summary
Closes #1892
The per-key data limits dialog did not handle Enter/Escape like other Manager inputs. Wire
@keydownon thepaper-dialog: Escape closes/cancels; Enter triggers save when the save action is enabled (and skips when focus is already on apaper-button).Test plan