Skip to content

update the highlight effect display for the confirm popup #1207

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 16 additions & 3 deletions src/ts/component/popup/confirm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const PopupConfirm = observer(class PopupConfirm extends React.Component<I.Popup

refButtons: any = null;
refCheckbox: any = null;
n = 0;
n: number = null;

constructor (props: I.Popup) {
super(props);
Expand All @@ -16,6 +16,7 @@ const PopupConfirm = observer(class PopupConfirm extends React.Component<I.Popup
this.onConfirm = this.onConfirm.bind(this);
this.onCancel = this.onCancel.bind(this);
this.onMouseEnter = this.onMouseEnter.bind(this);
this.onMouseLeave = this.onMouseLeave.bind(this);
this.setHighlight = this.setHighlight.bind(this);
};

Expand Down Expand Up @@ -50,8 +51,8 @@ const PopupConfirm = observer(class PopupConfirm extends React.Component<I.Popup
) : ''}

<div ref={ref => this.refButtons = ref} className="buttons">
{canConfirm ? <Button text={textConfirm} color={colorConfirm} className="c36" onClick={this.onConfirm} onMouseEnter={this.onMouseEnter} /> : ''}
{canCancel ? <Button text={textCancel} color={colorCancel} className="c36" onClick={this.onCancel} onMouseEnter={this.onMouseEnter} /> : ''}
{canConfirm ? <Button text={textConfirm} color={colorConfirm} className="c36" onClick={this.onConfirm} onMouseEnter={this.onMouseEnter} onMouseLeave={this.onMouseLeave} /> : ''}
{canCancel ? <Button text={textCancel} color={colorCancel} className="c36" onClick={this.onCancel} onMouseEnter={this.onMouseEnter} onMouseLeave={this.onMouseLeave} /> : ''}
</div>

<Error text={error} />
Expand Down Expand Up @@ -104,6 +105,12 @@ const PopupConfirm = observer(class PopupConfirm extends React.Component<I.Popup
return;
};

if (this.n === null) {
this.n = 0;
this.setHighlight();
return;
}

this.n += dir;
if (this.n < 0) {
this.n = buttons.length - 1;
Expand Down Expand Up @@ -160,6 +167,12 @@ const PopupConfirm = observer(class PopupConfirm extends React.Component<I.Popup
this.setHighlight();
};

onMouseLeave (e: any) {
$(e.currentTarget).removeClass('hover');

this.n = null;
}

setHighlight () {
const buttons = $(this.refButtons).find('.button');

Expand Down