Conditional create/update/delete actions leads to inconsistent alignment of actions on index #4844
-
Description:If your policy for a resource makes the various actions only display under certain conditions the index row actions can seem a little disorganised: ProposalShow disabled buttons instead of hiding them when not authorized Note: A disabled action will only be displayed if any row is authorized to run that action, so on a resource with just view enabled you would still get this: Alternative ProposalI propose adopting a grid style instead so that the above would display like this: Note: By using grid a column will only be defined if any row contains that action, so on a resource with just view enabled you would still get this: Changes Required in coreContainer <div class="flex items-center justify-end space-x-0 text-gray-400">After <div class="grid grid-cols-4 gap-x-2 items-center space-x-0 text-gray-400">Button <a class="toolbar-button hover:text-primary-500 px-2">After <a class="toolbar-button md:col-start-1 aspect-square hover:text-primary-500">Work aroundClick for CSS to make this work externally if not added to core[data-testid="resource-table"] tbody tr td:last-child > div {
display: grid;
grid-template-columns: [actions] 1fr [view] 1fr [edit] 1fr [delete] 1fr;
gap: 0 0.5rem;
}
[data-testid="resource-table"] tbody tr td:last-child > div > .toolbar-button {
aspect-ratio:1;
padding-left:0;
padding-right:0;
}
[data-testid="resource-table"] tbody tr td:last-child > div > div:first-child {
grid-column-start: actions;
}
[data-testid="resource-table"] tbody tr td:last-child > div > [aria-label="View"] {
grid-column-start: view;
}
[data-testid="resource-table"] tbody tr td:last-child > div > [aria-label="Edit"], [data-testid="resource-table"] tbody tr td:last-child > div > [aria-label="Edit Attached"] {
grid-column-start: edit;
}
[data-testid="resource-table"] tbody tr td:last-child > div > [aria-label="Delete"],
[data-testid="resource-table"] tbody tr td:last-child > div > [aria-label="Detach"],
[data-testid="resource-table"] tbody tr td:last-child > div > [aria-label="Restore"] {
grid-column-start: delete;
}Credit: Cephandrius (@ianrobertsFF) on discord https://discord.com/channels/297040613688475649/486650473336537098/1022908082268934185 |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 6 replies
-
|
I support this message |
Beta Was this translation helpful? Give feedback.
-
|
I suggest you always display the button in a disbled state when aligning with a Grid. |
Beta Was this translation helpful? Give feedback.
-
|
PR incoming for the second approach of showing disabled buttons. |
Beta Was this translation helpful? Give feedback.






PR incoming for the second approach of showing disabled buttons.