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 select grid #875

Merged
merged 5 commits into from
Aug 22, 2024
Merged

Fix select grid #875

merged 5 commits into from
Aug 22, 2024

Conversation

thecalcc
Copy link
Contributor

@thecalcc thecalcc commented Aug 20, 2024

SDUF-111

TODO:

  • Reopening doesn't cause the picker to stop listening for key events

@thecalcc
Copy link
Contributor Author

thecalcc commented Aug 21, 2024

Demo:

Screen.Recording.2024-08-21.at.14.38.19.mov

Note: Component updates weren't trickling down, thus the picked icon was always one step behind. I've chosen to use this.forceUpdate() when selecting an item to fix that. The other solution should be to pass the value down to the grid, but I went with forceUpdate as the cleaner approach.

label={this.props.label || "Icon"}
filterPlaceholder={this.props.filterPlaceholder || "Search..."}
label={this.props.label ?? "Icon"}
filterPlaceholder={this.props.filterPlaceholder ?? "Search..."}
Copy link
Member

Choose a reason for hiding this comment

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

we will need those translated I guess, maybe we should rather make those props mandatory

Copy link
Contributor Author

Choose a reason for hiding this comment

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

what if we treat those as the default fallback that's not translated, and if we need translations we pass them from the respective usage? im thinking here for all other components as well

Copy link
Member

Choose a reason for hiding this comment

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

we will need a mechanism to translate it within the framework probably, it wouldn't make much sense to redo it everywhere we use it. for now the fallback is ok

Copy link
Contributor Author

Choose a reason for hiding this comment

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

exactly, that's why I'd leave it

const VERTICAL_OFFSET = 3;
const HORIZONTAL_OFFSET = 1;
const PAGE_OFFSET = 15;
const FIRST_ROW_INDEXES = [0, 1, 2];
Copy link
Member

Choose a reason for hiding this comment

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

I wonder if it would be more readable to work with something like:

const GRID_COLS = 3;
const GRID_ROWS = 5;

or

const GRID_WIDTH = 3;
const GRID_HEIGHT = 5;

it's not clear why there would be any offsets

}

const GRID_COLS = 3;
const GRID_ROWS = 1;
Copy link
Member

Choose a reason for hiding this comment

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

imo there is not just 1 row, is there? in theory I would expect PAGE_ITEMS = GRID_COLS * GRID_ROWS

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yep, but I renamed the offsets to GRID_COLS & GRID_ROWS. Actually they're meant to be ROW_OFFSET & COL_OFFSET. do you think those names are better?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

confusion comes because this isn't a 2d array, it's 1d, so in theory there's no rows and cols

Copy link
Member

Choose a reason for hiding this comment

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

question is how many rows are actually there, so I would probably set proper value to GRID_ROWS so that the PAGE_SIZE = GRID_COLS * GRID_ROWS and where you use that GRID_ROWS to add/subtract 1 I would just use 1 there, that's not a magic number imo

Copy link
Member

Choose a reason for hiding this comment

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

and it's fine to be stored as an array, this should rather describe how it's rendered

const GRID_COLS = 3;
const GRID_ROWS = 1;
const PAGE_ITEMS = 15;
const FIRST_ROW_ITEMS_INDEXES = [0, 1, 2];
Copy link
Member

Choose a reason for hiding this comment

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

not sure if we need this one, you can check it via index < GRID_COLS

@thecalcc thecalcc merged commit 1ad6615 into superdesk:develop Aug 22, 2024
5 checks passed
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