-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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][Kibana Presentation] Options List new feature #149121
Changes from 2 commits
1273c60
c9400ba
9221eae
4474eab
421b8ef
88ddd8e
d802860
5e3a964
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -43,6 +43,7 @@ export const OptionsListPopover = ({ | |
const field = select((state) => state.componentState.field); | ||
|
||
const hideExclude = select((state) => state.explicitInput.hideExclude); | ||
const hideSearch = select((state) => state.explicitInput.hideSearch); | ||
const fieldName = select((state) => state.explicitInput.fieldName); | ||
const title = select((state) => state.explicitInput.title); | ||
const id = select((state) => state.explicitInput.id); | ||
|
@@ -52,12 +53,13 @@ export const OptionsListPopover = ({ | |
return ( | ||
<div | ||
id={`control-popover-${id}`} | ||
className={`optionsList__popover`} | ||
style={{ width: width > 300 ? width : undefined }} | ||
data-test-subj={`optionsList-control-popover`} | ||
aria-label={OptionsListStrings.popover.getAriaLabel(fieldName)} | ||
> | ||
<EuiPopoverTitle paddingSize="s">{title}</EuiPopoverTitle> | ||
{field?.type !== 'boolean' && ( | ||
{field?.type !== 'boolean' && !hideSearch && ( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This won't just hide the search bar, it will hide the entire top action bar, which currently includes the "Show only selections", "Clear selections", and "Sort" functionality: If this is the desired behaviour, that's fine! But in that case, I would recommend titling this property There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @Heenawter , you are right and I agree with changing the name to I was thinking if it makes sense to have a control to toggle the visibility of search bar. Do we want to go for a scenario where At least we do not have that requirement and I am good renaming it to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think hiding the entire top action bar makes sense to me! :) I assume if this is being done, the solution knows that there are < 10 options to select from. So searching, sorting, etc. shouldn't be necessary in these cases, since the options list size is manageable without them 👍 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done. |
||
<OptionsListPopoverActionBar | ||
showOnlySelected={showOnlySelected} | ||
setShowOnlySelected={setShowOnlySelected} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why the addition of this extra class? Is the
style
attribute below not covering this?I'm also suspicious that the
scss
import in the definition of this class may have contributed to the+10kb
increase in async chunks, which is a bit worrying.... Not sure about that, though - just a guess :)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Heenawter not it was not necessary, since there already was
scss
file so I just added the style in that.also, I will check about bundle size increase if it was because of
scss
. But I just wanted to have consistency in the width.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@logeekal I guess I'm still a bit confused. Right below this, we have:
I think if we are going the route of styling through a class, then we should remove this - styling through both a class name and a
style
attribute for a single component can cause two sources of truth, which is hard to follow imo. For example, after this addition, is the minimum width of the popover300px
or is it$controlMinWidth
(which is actually a variable meant to reference the size of the control and not the popover)?For reference, this is the way it works currently for a
small
control:There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are right and it was my fault I did not pay attention to the style prop. Previously, if
width
<300
, then we were setting width asundefined
, not300
. So now I have changedmin-width
to 300px. Let me know if it make sense now.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think the new
min-width
is working quite as expected, either. Here's what happens when you shrink the window to be less than300px
wide with your current code:Notice that the white part of the popover shrinks, but neither the inner contents nor the footer do - so you end up with a weird "overhang" effect. Whereas this is what happens with the original sizing code:
The sizing of the popovers is finicky! So we don't actually technically have a minimum size - we are allowing the popover to decide the minimum size, hence setting the width to
undefined
when the width of the control is less than300
. Basically, the original code says "If the width of the control is<= 300
, then let the popover be in control of its own width; otherwise, set the popover width to be the same size as the control width."If you can figure out a better way to handle this, I'd be down - but in its current state, not a fan of what happens when you set
min-width
like that.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @Heenawter for diving into this problem. However, I think it might not be that big of a problem. Please bear with me for the explanation.
It looks like there are 4 ways we can go about this problem:
Setting
width
toundefined
if width < 300 i.e.width: width > 300 ? width : undefined
ActionBar
so I guess we will need to havewidth
for sure.Not setting
min-width
and setting width to the size of option list. Issue with this is that, option list can get very small in some cases. See below:Because of these 2 reasons, I think setting
min-width
becomes important. Now one option is to set the min-width of the popover content as done above i.emin-width : 300px
screen
width will never( rarely?) be<300
causing the issue that you just highlighted.Solution to the problem in the 3rd approach is passing
panelStyle
to EuiPopover.may
give rise to other positioning problems mentioned here.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ahh, thank you for the screenshots! That helps a lot to understand why you added that - makes total sense. I did not consider how the width would be impacted when the action bar was not present. I think that, given what you've outlined, sticking with your current
min-width
approach seems totally fair!There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🙏 Thank you very much.