-
Notifications
You must be signed in to change notification settings - Fork 843
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
[EuiDataGrid] Toolbar layout configuration API #5346
Comments
Responding to @cchaos's comment (#5334 (comment)) here to keep the conversation going:
Hm, while there's always a balance to be struck between customization vs. consistency, I'm not seeing the consistency issue when we're allowing users to put in any amount of custom content to the left or right of our controls in any case. In theory if someone adds enough custom content to the right of the fullscreen button, then it's no longer in the place users typically expect (top-right-most button in the toolbar) and the UX is no longer consistent in any case. I'd personally lean more towards customization than consistency based on how I'm seeing other teams use the toolbar (e.g. the Discover team literally hides all our buttons and only uses their own). Also, forgot to tag @chandlerprall in the original issue description so doing so now! |
Yeah I think mainly, I actually want to avoid any content going to the right of the fullscreen option, and lock that location on the far right. Also what's the scalability of this array method? This feels more like an opt-in than opt-out so when we add more controls, all consumers would need to add this in manually. For instance, if/when we back in that "no. of results" portion, it would never show up by default. |
Maybe I'm confused, but your left/middleLeft/middleRight/right proposal would still allow that wouldn't it? Also, wouldn't that still break Security and Observability's current implementation since they're using
If consumers don't pass a custom array (or empty array if they want nothing), we would just fall back to what's in your mock, which would look like this: toolbarConfiguration = {
leftToolbar: [
showResults, // when we add this
showColumnSelector,
showSortSelector,
],
rightToolbar: [
showDisplayConfig,
showFullscreen,
],
} So DataGrid consumers that don't need a custom toolbar layout will still get new toolbar defaults - but yeah people who pass in a custom layout will need to manually add new controls. IMO, this is how it should work - to use the Discover example where they hide everything but their own custom content, that's basically what they want in any case. |
@cchaos do we want to keep the |
I wasn't thinking about keeping fullscreen locked to the right in my original proposal. (Basically I'm changing my mind 😆 ). But if they just want to turn off the sort selector they have to completely re-establish the configuration. I'm just thinking that it's really tough to change just a single thing using this method. If we wanted to make it complicated, we could accept both which would look something like: toolbarConfiguration = {
showResults, // when we add this
showColumnSelector,
showSortSelector,
showFullScreen,
showDisplayConfig,
// Or customize:
leftToolbar: [
showResults, // when we add this
showColumnSelector,
customButton,
showSortSelector,
],
rightToolbar: [
customButton, // shows to the left of the display options button
],
} |
Sorry I meant to write more on the |
Gotcha, sorry for the confusion, and thanks for clarifying! If we don't want fully customizable toolbar layouts and instead just a limited number of places users can add their custom controls, can I suggest just I think there's a couple data structures we can consider for that approach: Simple: additionalControls={{
left: ReactNode, // If a single ReactNode is passed instead of an object with left/right keys, the react node defaults to 'left'
right: ReactNode,
}} Array: additionalControls={[
{
item: ReactNode, // If a single ReactNode is passed instead of an array, it defaults to this
position: 'left',
},
{
item: ReactNode,
position: 'right',
},
{
item: ReactNode,
position: 'right',
},
]} Between the two I think I lean towards the simpler left/right obj keys, since ReactNodes can contain multiple nodes (which is how consumers currently add multiple EuiButtons in any case) I don't see a need for an array. Thoughts? |
Ahh good call, I keep forgetting about the results!
👍 I'd lean towards this for now and note it as a breaking change from the current behavior (+ clearly document the expected append/prepend positions in our props). I'd be surprised if teams need something significantly more complex than this. Does this sound good to everyone else in terms of moving ahead? |
Also, sorry to detour into the additionalControls={{
data: ReactNode,
display: ReactNode,
}} TBH, I don't feel super strongly about this and would be fine sticking to left/right, just wanted to throw that option out there 🤔 |
I'm good with moving the custom buttons to the right of the left 😆 . There's more ambiguity in |
Closing and moving this work back into #5334, since the proposed way forward is backwards-compatible with the current API and doesn't require a breaking prop change |
Initial mock: #5080 (comment)
PR implementation, with caution from Dave that this will break some custom CSS/positioning by the Security and Obs teams: #5334 (comment)
API proposal from @cchaos: #5334 (comment)
API proposal from @constancecchen: #5334 (comment)
The text was updated successfully, but these errors were encountered: