Skip to content

[WEB-31] Bug renaming reordering issue (and also WEB-68) #377

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

Merged
merged 7 commits into from
Sep 4, 2023

Conversation

josh-ramos-22
Copy link
Contributor

@josh-ramos-22 josh-ramos-22 commented Jul 13, 2023

Why are the changes needed?

Currently, when you rename a file in the folder and refresh, the renamed file is repositioned to the end of the file list, jumbling the original order.

WEB-68

In this ticket I also happened to fixed the issue covered in the ticket WEB-68 (https://csesoc.atlassian.net/browse/WEB-68) where input boxes were rendered with old initial values.

Changes

The reason that files are reordered upon renaming is due to how UPDATEs in PostgreSQL works. PostgreSQL tables store their records in an undefined order, hence we cannot assume that a table retains its original order after an UPDATE.

A possible fix to this would to be adding an explicit ordering to the query that fetches the files from the database. However this seems infeasible as there does not seem to be an existing datetime_created or serial field in the existing database schema to explicitly sort the files on the desired order.

This PR contains an alternate solution which displays files in alphabetical order. Additionally, the comparator used also ensures that all folders are displayed before files.

WEB-68

The reason why initial input values were not updating was because these elements are actually rendered multiple times upon refresh.

First, the file containers render with the data stored on the frontend in redux, which is in the initial order before the renaming of the file. Then, after the call to the backend, these values are updated with the new order. However, since the files will be in a new order and initial useState() values are only considered during the first render, the initial values will not be updated. This causes a mismatch between file names and initial values.

To fix this, I explicitly called setInputName(name) in the event handler for when the file name label is double clicked to ensure that the proper initial value is displayed.

Copy link
Contributor

@lauraw0 lauraw0 left a comment

Choose a reason for hiding this comment

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

lookss amazinggg merge whenever

@josh-ramos-22 josh-ramos-22 merged commit bdf7fca into main Sep 4, 2023
@josh-ramos-22 josh-ramos-22 deleted the WEB_31_BUG_Renaming_reordering_issue branch September 4, 2023 00:55
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.

2 participants