Add action when hitting enter on poster list page

This commit is contained in:
Lucas BEE 2018-08-18 18:38:42 +08:00
parent 1c19febf6f
commit 26b91c84b4
4 changed files with 21 additions and 0 deletions

View File

@ -10,6 +10,7 @@ export default function Poster(props) {
<img
src={props.data.get("poster_url")}
onClick={props.onClick}
onDoubleClick={props.onDoubleClick}
/>
</a>
</div>

View File

@ -105,6 +105,8 @@ export default class ListPosters extends React.PureComponent {
loadMore={this.loadMore}
selectedImdbId={this.props.selectedImdbId}
selectPoster={this.props.onClick}
onDoubleClick={this.props.onDoubleClick}
onKeyEnter={this.props.onKeyEnter}
/>
</div>
);
@ -129,6 +131,10 @@ class Posters extends React.PureComponent {
"j": 6,
});
if (event.key === "Enter") {
this.props.onKeyEnter(this.props.selectedImdbId);
}
if (! keyToDiff.has(event.key) ) {
return;
}
@ -199,6 +205,7 @@ class Posters extends React.PureComponent {
key={`poster-${imdbId}`}
selected={selected}
onClick={() => this.props.selectPoster(imdbId)}
onDoubleClick={() => this.props.onDoubleClick(imdbId)}
/>
</div>
)

View File

@ -92,6 +92,8 @@ class MovieList extends React.PureComponent {
updateFilter={this.props.updateFilter}
filter={this.props.filter}
onClick={this.props.selectMovie}
onDoubleClick={function() { return; }}
onKeyEnter={function() { return; }}
params={this.props.params}
router={this.props.router}
loading={this.props.loading}

View File

@ -23,6 +23,15 @@ const mapDispatchToProps = (dispatch) =>
deleteShowFromWishlist, getShowDetails, updateFilter }, dispatch)
class ShowList extends React.PureComponent {
constructor(props) {
super(props);
this.showDetails = this.showDetails.bind(this);
}
showDetails(imdbId) {
return this.props.router.push("/shows/details/" + imdbId);
}
render() {
let selectedShow;
if (this.props.selectedImdbId !== "") {
@ -40,6 +49,8 @@ class ShowList extends React.PureComponent {
selectedImdbId={this.props.selectedImdbId}
filter={this.props.filter}
onClick={this.props.selectShow}
onDoubleClick={this.showDetails}
onKeyEnter={this.showDetails}
router={this.props.router}
params={this.props.params}
loading={this.props.loading}