Skip to content

Commit

Permalink
Revert "fix build errors"
Browse files Browse the repository at this point in the history
This reverts commit ddae063.
  • Loading branch information
panaC committed Nov 30, 2023
1 parent ddae063 commit 954a1fe
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 21 deletions.
40 changes: 20 additions & 20 deletions src/renderer/common/components/dialog/Dialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ class Dialog extends React.Component<React.PropsWithChildren<IProps>, undefined>
<div
role="document"
id={this.props.id}
className={classNames(className, stylesModals.modal_dialog, this.props.size === "small" ? undefined : stylesModals.modal_dialog)}
className={classNames(className, stylesModals.modal_dialog, this.props.size === "small" ? undefined : stylesModals.modal_dialog_full )}
>
<div className={stylesModals.modal_dialog_header}>
<h2>{this.props.title}</h2>
Expand All @@ -126,10 +126,10 @@ class Dialog extends React.Component<React.PropsWithChildren<IProps>, undefined>
// ></form>
this.props.noFooter // cf PublicationInfoManager
? <div
className={classNames(stylesModals.modal_dialog_body)}
>
{content}
</div>
className={classNames(stylesModals.modal_dialog_body)}
>
{content}
</div>
: <>
<div
className={classNames(stylesModals.modal_dialog_body, this.props.noCentering ? undefined : stylesModals.modal_dialog_body_centered)}
Expand All @@ -140,21 +140,21 @@ class Dialog extends React.Component<React.PropsWithChildren<IProps>, undefined>
}
}

// onKeyDown={(e) => {
// // See onKeyUp below for explanation
// console.log("DIALOG DIV KEY DOWN ", e.key, (e.target as HTMLElement)?.tagName);
// if (e.key === "Enter" && (e.target as HTMLElement)?.tagName === "INPUT") {
// // e.stopPropagation();
// e.preventDefault();
// }
// }}
// onKeyUp={(e) => {
// // WARNING: onKeyUp alone here instead of onKeyDown (or onKeyDown alone too) causes the footer cancel button below to trigger when the keyboard focus is located inside a text input!! (crazy Chromium bug? or normal form/submit edge case due to submit button being disabled??) The onKeyDown above fixes this, but a problem remains: keyUp is captured immediately after pressing ENTER (full click event) on the calling site button that opens the popup dialog, resulting in the modal closing immediately! (thus the additional required check for matching keyDown)
// console.log("DIALOG DIV KEY UP ", e.key, (e.target as HTMLElement)?.tagName);
// if (e.key === "Enter" && (e.target as HTMLElement)?.tagName === "INPUT" && !this.props.submitButtonDisabled) {
// this.submitForm(e);
// }
// }}
// onKeyDown={(e) => {
// // See onKeyUp below for explanation
// console.log("DIALOG DIV KEY DOWN ", e.key, (e.target as HTMLElement)?.tagName);
// if (e.key === "Enter" && (e.target as HTMLElement)?.tagName === "INPUT") {
// // e.stopPropagation();
// e.preventDefault();
// }
// }}
// onKeyUp={(e) => {
// // WARNING: onKeyUp alone here instead of onKeyDown (or onKeyDown alone too) causes the footer cancel button below to trigger when the keyboard focus is located inside a text input!! (crazy Chromium bug? or normal form/submit edge case due to submit button being disabled??) The onKeyDown above fixes this, but a problem remains: keyUp is captured immediately after pressing ENTER (full click event) on the calling site button that opens the popup dialog, resulting in the modal closing immediately! (thus the additional required check for matching keyDown)
// console.log("DIALOG DIV KEY UP ", e.key, (e.target as HTMLElement)?.tagName);
// if (e.key === "Enter" && (e.target as HTMLElement)?.tagName === "INPUT" && !this.props.submitButtonDisabled) {
// this.submitForm(e);
// }
// }}
}
>
{content}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import * as React from "react";
import { connect } from "react-redux";
import { DialogTypeName } from "readium-desktop/common/models/dialog";
import { readerActions } from "readium-desktop/common/redux/actions";
import * as dialogActions from "readium-desktop/common/redux/actions/dialog";
import { PublicationView } from "readium-desktop/common/views/publication";
Expand Down Expand Up @@ -41,6 +42,7 @@ export class CatalogControls extends React.Component<IProps, undefined> {
super(props);

this.handleRead = this.handleRead.bind(this);
this.deletePublication = this.deletePublication.bind(this);
this.exportPublication = this.exportPublication.bind(this);
}

Expand Down Expand Up @@ -76,6 +78,10 @@ export class CatalogControls extends React.Component<IProps, undefined> {
);
}

private deletePublication(e: TMouseEventOnButton) {
e.preventDefault();
this.props.openDeleteDialog();
}
private exportPublication(e: TMouseEventOnButton) {
e.preventDefault();

Expand All @@ -87,6 +93,7 @@ export class CatalogControls extends React.Component<IProps, undefined> {

private handleRead(e: TMouseEventOnButton) {
e.preventDefault();

this.props.openReader();
}
}
Expand All @@ -97,7 +104,13 @@ const mapDispatchToProps = (dispatch: TDispatch, props: IBaseProps) => {
dispatch(dialogActions.closeRequest.build());
dispatch(readerActions.openRequest.build(props.publicationView.identifier));
},

openDeleteDialog: () => {
dispatch(dialogActions.openRequest.build(DialogTypeName.DeletePublicationConfirm,
{
publicationView: props.publicationView,
},
));
},
};
};

Expand Down

0 comments on commit 954a1fe

Please sign in to comment.