Skip to content

Commit

Permalink
Merge pull request #101 from sdasda7777/sdasda7777_scroll
Browse files Browse the repository at this point in the history
  • Loading branch information
pengx17 authored Mar 11, 2024
2 parents d88008d + feb9184 commit 8f96f42
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
7 changes: 4 additions & 3 deletions src/PageTabs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -148,10 +148,11 @@ const Tabs = React.forwardRef<HTMLElement, TabsProps>(
return (
<div
onClick={(e) => onClickTab(tab, e.shiftKey)}
onAuxClick={onClose}
onDoubleClick={() => onPinTab(tab)}
onContextMenu={(e) => {
e.preventDefault();
console.log(e);
// onAuxClick={/*onClose*/}
// TODO: show the same context menu like right-clicking the title?
console.log("Not implemented yet");
}}
Expand Down Expand Up @@ -426,7 +427,7 @@ export function useActiveTab(tabs: ITabInfo[]) {

tab = { ...tab, ...p };
if (tab.scrollTop) {
mainContainerScroll({ top: tab.scrollTop });
setTimeout(() => { mainContainerScroll({ top: tab.scrollTop }); }, 250);
}
pageRef.current = tab;
setPage(tab);
Expand Down Expand Up @@ -654,7 +655,7 @@ export function PageTabs(): JSX.Element {
// remember current page's scroll position
if (idx !== -1) {
const scrollTop =
top?.document.querySelector("#main-container")?.scrollTop;
top?.document.querySelector("#main-content-container")?.scrollTop;

setTabs(
produce(tabs, (draft) => {
Expand Down
2 changes: 1 addition & 1 deletion src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ export const useScrollWidth = <T extends HTMLElement>(
};

export const mainContainerScroll = (scrollOptions: ScrollToOptions) => {
top?.document.querySelector("#main-container")?.scrollTo(scrollOptions);
top?.document.querySelector("#main-content-container")?.scrollTo(scrollOptions);
};

export const isBlock = (t: ITabInfo) => {
Expand Down

0 comments on commit 8f96f42

Please sign in to comment.