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

feat: update select dropdown to match multiselect one #516

Merged
merged 3 commits into from
Sep 22, 2023
Merged

Conversation

f-necas
Copy link
Collaborator

@f-necas f-necas commented Jul 5, 2023

An overlay has been set to be as closed as the multiselect dropdown.

Sometimes the selected value is a string or an object. I made the majority of the changes in the dropdown component in order to keep the original behavior of each parent component.

@github-actions
Copy link
Contributor

github-actions bot commented Jul 5, 2023

Affected libs: feature-dataviz, feature-record, feature-router, feature-editor, ui-catalog, feature-catalog, ui-inputs, feature-search, feature-map, ui-elements, ui-search,
Affected apps: datafeeder, metadata-editor, datahub, demo, webcomponents, search, metadata-converter, map-viewer,

  • 🚀 Build and deploy storybook and demo on GitHub Pages
  • 📦 Build and push affected docker images

@f-necas f-necas marked this pull request as ready for review July 6, 2023 08:41
@f-necas f-necas requested a review from jahow July 6, 2023 08:41
@f-necas f-necas force-pushed the ui-sort-dropdown branch from 1f3eb6a to a49a7a7 Compare July 6, 2023 10:47
@f-necas f-necas added enhancement Proposal for a new feature minor feature labels Jul 6, 2023
@fgravin fgravin requested a review from tkohr July 13, 2023 12:07
Copy link
Collaborator

@tkohr tkohr left a comment

Choose a reason for hiding this comment

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

Thanks @f-necas for the big work! The visual result is really nice and identical to the multi-dropdown.

However, the app currently breaks if choice is undefined in the dropdown-selector. Can easily be tested with records without data for the previews. Also noticed two minor issues in the UI:

  • The values in the orgs sort now wrap. Do you think this could be prevented?
    orgs

  • The sort label is not properly aligned on mobile.
    mobile

I've left corresponding comments inline.

@f-necas f-necas force-pushed the ui-sort-dropdown branch 2 times, most recently from badf863 to 4a415f3 Compare July 17, 2023 08:03
@f-necas
Copy link
Collaborator Author

f-necas commented Jul 17, 2023

Thanks for your review @tkohr. I've updated the code in order to :

  1. Display only a part of choice label if it's too long (I've seen in my dataset a long text which overflow the entire page)
  2. Set a min-width in order to have a correct display for sort by. (I could take the longest label but it may be related to the first point (very long select) and setting a whitespace-nowrap in choices labels overflows the overlay)
  3. Set the number of max rows as constant
  4. Put a conditional display if choices isn't set. ( I think we won't need the select if there's no value ?)

@f-necas f-necas requested a review from tkohr July 17, 2023 08:10
@f-necas f-necas force-pushed the ui-sort-dropdown branch from 4a415f3 to f80282b Compare July 17, 2023 08:15
Comment on lines 72 to 75
return (
this.selectedChoice.label.substring(0, 50) +
(this.selectedChoice.label.length > 50 ? '...' : '')
)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can't we achieve this with a truncate via CSS?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I have done a truncate in css BUT couldn't set parent as flex in map-view component. When external link is displayed , it's not on the same line. Couldn't figure it out why flex is breaking the css truncate thing.

min-w-0 is also mandatory to have the truncate working...

Copy link
Member

Choose a reason for hiding this comment

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

I haven't followed the discussion but TW provide a truncate class for ellipsis. It's not about flex.
https://tailwindcss.com/docs/text-overflow#truncate

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I haven't followed the discussion but TW provide a truncate class for ellipsis. It's not about flex. https://tailwindcss.com/docs/text-overflow#truncate

Yeah I know and use it already, but the flex class on a parent breaks his behaviour.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Hum, indeed it doesn't seem simple to make the cascaded truncate work within the flex here. A <div class="truncate"> wrapper directly under the flex helps to apply the truncate further down, but also cuts borders etc. because of the overflow-hidden.
We really need to keep the flex justify-end layout in the map-view.component, though, to keep a fitting design for short/normal dropdown entries.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@jahow @fgravin What do you think of it ?

@f-necas f-necas requested a review from tkohr July 18, 2023 12:27
@@ -21,6 +22,7 @@ export default {
imports: [
ChartComponent,
HttpClientModule,
OverlayModule,
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 should import the UiInputs module here instead, as OverlayModule is an underlying dependency

Comment on lines 60 to 69
<input
class="w-[0px] h-[18px] align-text-top shrink-0"
type="text"
[checked]="isSelected(choice)"
(click)="onSelectValue(choice)"
/>
Copy link
Collaborator

Choose a reason for hiding this comment

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

this has no reason to be there; instead, of isSelected(choice) is true, the following span should be highlighted just like in a native select:
image

@@ -1,23 +1,25 @@
<div class="w-full h-full flex flex-col">
<div
class="flex flex-col space-y-2 sm:flex-row sm:space-y-0 sm:space-x-2 justify-between text-[13px]"
class="flex flex-col flex-wrap space-y-2 sm:flex-row sm:space-y-0 sm:space-x-2 justify-between text-[13px] gap-4"
Copy link
Collaborator

Choose a reason for hiding this comment

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

In principle, when modifying a presentation component, we shouldn't have to modify anything that uses this component. Otherwise this indicates that the encapsulation is broken and that our changes are leaking "outside" of the modified component scope.

In that case I think it is acceptable to adjust options because the dropdown is a little bit larger, but modifying the layout (introducing flex-wrap etc.) is a too big change in my opinion.

@jahow
Copy link
Collaborator

jahow commented Jul 27, 2023

Thanks for the extensive work on this @f-necas, this PR is clearly very close to be good to go. However as discussed I think we should refrain from merging it before shipping 1.1, as it might have unexpected side effects and is IMO not strictly required for the release. Sorry if that is disappointing 😬

@jahow jahow modified the milestones: 1.2.0, 2.0.0 Jul 27, 2023
@coveralls
Copy link

coveralls commented Aug 25, 2023

Coverage Status

coverage: 81.642% (-4.3%) from 85.915% when pulling 1519aee on ui-sort-dropdown into a9fd646 on main.

@f-necas f-necas requested review from jahow and fgravin August 25, 2023 17:50
@f-necas f-necas removed request for fgravin and tkohr September 1, 2023 10:13
@f-necas f-necas requested review from jahow and removed request for jahow September 1, 2023 10:14
* show selected item

Also modified button:

* removing minus margin and add hidden border to buttons
Copy link
Collaborator

@jahow jahow left a comment

Choose a reason for hiding this comment

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

I think we're in a pretty good state now. @f-necas you can merge whenever you feel that the PR is ready! Thanks for the continued effort.

@f-necas f-necas merged commit f491bdb into main Sep 22, 2023
5 checks passed
@jahow jahow deleted the ui-sort-dropdown branch October 19, 2023 08:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Proposal for a new feature minor feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants