Skip to content
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

Fix #19068: While user in Pagination, Browser Back button takes them to start page #19229

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

shrushti2000
Copy link
Contributor

Fixes #19068

Screen.Recording.2025-01-03.at.7.39.54.PM.mov

Type of change:

  • Bug fix
  • Improvement
  • New feature
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation

Checklist:

  • I have read the CONTRIBUTING document.
  • My PR title is Fixes <issue-number>: <short explanation>
  • I have commented on my code, particularly in hard-to-understand areas.
  • For JSON Schema changes: I updated the migration scripts or explained why it is not needed.

Copy link
Contributor

github-actions bot commented Jan 3, 2025

Hi there 👋 Thanks for your contribution!

The OpenMetadata team will review the PR shortly! Once it has been labeled as safe to test, the CI workflows
will start executing and we'll be able to make sure everything is working as expected.

Let us know if you need any help!

Copy link
Contributor

github-actions bot commented Jan 3, 2025

Hi there 👋 Thanks for your contribution!

The OpenMetadata team will review the PR shortly! Once it has been labeled as safe to test, the CI workflows
will start executing and we'll be able to make sure everything is working as expected.

Let us know if you need any help!

Copy link
Contributor

github-actions bot commented Jan 3, 2025

Hi there 👋 Thanks for your contribution!

The OpenMetadata team will review the PR shortly! Once it has been labeled as safe to test, the CI workflows
will start executing and we'll be able to make sure everything is working as expected.

Let us know if you need any help!

Copy link
Contributor

github-actions bot commented Jan 6, 2025

Hi there 👋 Thanks for your contribution!

The OpenMetadata team will review the PR shortly! Once it has been labeled as safe to test, the CI workflows
will start executing and we'll be able to make sure everything is working as expected.

Let us know if you need any help!

cursorValue: string;
currentPage: number;
}>();
const currentPath = window.location.pathname;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

instead use useCustomLocation

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

[cursorState.cursorType]: cursorState.cursorValue,
limit: pageSize,
});
handlePageChange(cursorState.currentPage as number);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can pass cursor value to page handler and make it work as optional param so if we want to store it we can pass it else it won't be in effect

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just to clarify once, do you mean:
Passing cursorValue as an optional parameter in tablePaginationHandler?

const tablePaginationHandler = useCallback( ({ cursorType, currentPage, cursorValue}: PagingHandlerParams) => { if (cursorType && cursorValue) { getSchemaTables({ [cursorType]: paging[cursorType] }); storeCursor({ cursorType: cursorType, cursorValue: cursorValue, currentPage: currentPage, }); } handlePageChange(currentPage); }, [paging, getSchemaTables, storeCursor, handlePageChange] );

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am pointing at this: handlePageChange

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

handlePageChange is simply a setter function for currentPage in usePaging
handlePageChange: setCurrentPage

@@ -93,6 +94,7 @@ const DatabaseSchemaPage: FunctionComponent = () => {
const { t } = useTranslation();
const { getEntityPermissionByFqn } = usePermissionProvider();
const pagingInfo = usePaging(PAGE_SIZE);
const { storeCursor, getStoredCursor } = usePaging();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We will be having both in line no. 96 no?
Also we are not passing default values from location?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

addressed

Copy link
Contributor

github-actions bot commented Jan 7, 2025

Hi there 👋 Thanks for your contribution!

The OpenMetadata team will review the PR shortly! Once it has been labeled as safe to test, the CI workflows
will start executing and we'll be able to make sure everything is working as expected.

Let us know if you need any help!

interface CursorState {
cursorType: CursorType | null;
cursorValue: string | null;
currentPage: number | null;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

currentPage is already there so no need to pull it here sepratly

Comment on lines 44 to 49
storeCursor: (params: {
cursorType: CursorType | null;
cursorValue: string | null;
currentPage: number | null;
}) => void;
getStoredCursor: () => CursorState;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's follow same naming as above adn rename getter setter as below
handlePagingCursorChange
pagingCursor

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Comment on lines 73 to 92
const storeCursor = useCallback(
({
cursorType,
cursorValue,
currentPage,
}: {
cursorType: CursorType | null;
cursorValue: string | null;
currentPage: number | null;
}) => {
history.replace({
state: {
cursorType,
cursorValue,
currentPage,
},
});
},
[]
);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function is not storing the cursor it's actually updating location state let's rename something to convey the same

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Comment on lines 97 to 103
return cursorState
? {
cursorType: cursorState.cursorType || null,
cursorValue: cursorState.cursorValue || null,
currentPage: cursorState.currentPage || null,
}
: { cursorType: null, cursorValue: null, currentPage: null };
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
return cursorState
? {
cursorType: cursorState.cursorType || null,
cursorValue: cursorState.cursorValue || null,
currentPage: cursorState.currentPage || null,
}
: { cursorType: null, cursorValue: null, currentPage: null };
return {
cursorType: cursorState.cursorType || null,
cursorValue: cursorState.cursorValue || null,
currentPage: cursorState.currentPage || null,
};

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

[cursorState.cursorType]: cursorState.cursorValue,
limit: pageSize,
});
handlePageChange(cursorState.currentPage as number);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am pointing at this: handlePageChange

Copy link
Contributor

github-actions bot commented Jan 7, 2025

Hi there 👋 Thanks for your contribution!

The OpenMetadata team will review the PR shortly! Once it has been labeled as safe to test, the CI workflows
will start executing and we'll be able to make sure everything is working as expected.

Let us know if you need any help!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

While user in Pagination, Browser Back button takes them start page
2 participants