Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Commit

Permalink
Merge pull request #6844 from SimonBrandner/fix/firefox-revert
Browse files Browse the repository at this point in the history
Revert Firefox composer deletion hacks
  • Loading branch information
dbkr authored Sep 20, 2021
2 parents 5b8279d + bce4d44 commit 3a1a488
Showing 1 changed file with 0 additions and 26 deletions.
26 changes: 0 additions & 26 deletions src/components/views/rooms/BasicMessageComposer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -499,9 +499,6 @@ export default class BasicMessageEditor extends React.Component<IProps, IState>
handled = true;
} else if (event.key === Key.BACKSPACE || event.key === Key.DELETE) {
this.formatBarRef.current.hide();
if (!event.ctrlKey && !event.metaKey) {
handled = this.fakeDeletion(event.key === Key.BACKSPACE);
}
}

if (handled) {
Expand Down Expand Up @@ -567,29 +564,6 @@ export default class BasicMessageEditor extends React.Component<IProps, IState>
}
};

/**
* TODO: Remove when Debian moves to newer version of Firefox
* On Firefox 78 no event emitted when the user tries to delete pills.
* Therefore we need to fake what would normally happen
* @param direction in which to delete
* @returns handled
*/
private fakeDeletion(backward: boolean): boolean {
const selection = document.getSelection();
// Use the default handling for ranges
if (selection.type === "Range") return false;

this.modifiedFlag = true;
const { caret, text } = getCaretOffsetAndText(this.editorRef.current, selection);

// Do the deletion itself
if (backward) caret.offset--;
const newText = text.slice(0, caret.offset) + text.slice(caret.offset + 1);

this.props.model.update(newText, backward ? "deleteContentBackward" : "deleteContentForward", caret);
return true;
}

private async tabCompleteName(): Promise<void> {
try {
await new Promise<void>(resolve => this.setState({ showVisualBell: false }, resolve));
Expand Down

0 comments on commit 3a1a488

Please sign in to comment.