Skip to content

Docdiff should not apply the 'd' hotkey in textareas #205

Closed
@davidfischer

Description

@davidfischer

Docdiff doesn't apply the d hotkey when typing in <input> fields but should apply similar checks to <textarea> fields.

addons/src/hotkeys.js

Lines 49 to 69 in ff8baf2

_handleKeydown = (e) => {
// Close docdiff with single-stroke `d` (no Ctrl, no Shift, no Alt and no Meta)
// (I'm checking `document.activeElement` to check if it not inside an INPUT to avoid enable/disable while typing on forms)
// Read more about these decisions at https://github.com/readthedocs/addons/issues/80
let event;
// DocDiff
if (
this.docDiffHotKeyEnabled &&
keyboardEventToString(e) ===
this.config.addons.hotkeys.doc_diff.trigger &&
document.activeElement.tagName !== "INPUT"
) {
if (this.docDiffShowed) {
event = new CustomEvent(EVENT_READTHEDOCS_DOCDIFF_HIDE);
this.docDiffShowed = false;
} else {
event = new CustomEvent(EVENT_READTHEDOCS_DOCDIFF_ADDED_REMOVED_SHOW);
this.docDiffShowed = true;
}
}

You can see this bug in the notes field on ethicalads.io where the 'd' character cannot be typed.

Metadata

Metadata

Assignees

Labels

AcceptedAccepted issue on our roadmapBugA bug

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions