Skip to content

Commit

Permalink
feat: implement scroll to view in rightsidebar for legacy application…
Browse files Browse the repository at this point in the history
… path on edit
  • Loading branch information
dot-mike committed Dec 21, 2024
1 parent e06633f commit 0c7e07e
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/renderer/components/DropdownInputField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ export type DropdownInputFieldProps = InputFieldProps & {
onItemSelect?: (text: string, index: number) => void;
/** Function for getting a reference to the input element. Called whenever the reference could change. */
inputRef?: RefFunc<InputElement>;
/** Called when the drop-down content is expanded or collapsed. */
onExpand?: (expanded: boolean) => void;
};

type DropdownInputFieldState = {
Expand Down Expand Up @@ -204,7 +206,12 @@ export class DropdownInputField extends React.Component<DropdownInputFieldProps,

onExpandButtonMouseDown = (): void => {
if (!this.props.disabled) {
this.setState({ expanded: !this.state.expanded });
const newExpandedState = !this.state.expanded;
this.setState({ expanded: newExpandedState }, () => {
if (this.props.onExpand) {
this.props.onExpand(newExpandedState);
}
});
}
};

Expand Down
10 changes: 10 additions & 0 deletions src/renderer/components/RightBrowseSidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -852,6 +852,7 @@ export class RightBrowseSidebar extends React.Component<RightBrowseSidebarProps,
text={game.legacyApplicationPath}
placeholder={strings.noApplicationPath}
onChange={this.onApplicationPathChange}
onExpand={this.onApplicationPathExpand}
editable={editable}
items={suggestions && filterSuggestions(suggestions.applicationPath) || []}
onItemSelect={text => this.props.onEditGame({ legacyApplicationPath: text })} />
Expand Down Expand Up @@ -969,6 +970,15 @@ export class RightBrowseSidebar extends React.Component<RightBrowseSidebarProps,
}
}

onApplicationPathExpand = () => {
if (this.state.middleScrollRef.current) {
this.state.middleScrollRef.current.scrollTo({
top: this.state.middleScrollRef.current.scrollHeight,
behavior: 'smooth'
});
}
}

renderDeleteGameButton({ confirm, extra }: ConfirmElementArgs<LangContainer['browse']>): JSX.Element {
return (
<div
Expand Down

0 comments on commit 0c7e07e

Please sign in to comment.