-
Notifications
You must be signed in to change notification settings - Fork 367
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
change: [M3-8533, M3-8761] - Fix firewall rules table and Replace react-beautiful-dnd
with dnd-kit
lib
#11127
Conversation
Coverage Report: ❌ |
c42e8b1
to
33ded4a
Compare
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.
Fantastic work @pmakode-akamai, and really appreciate considering going with a more holistic refactor, including replacing a non-supported library.
Implementation, markup and styling looks great (in both modes) for the most part, leaving some comments that shouldn't take too much extra work to implement.
33ded4a
to
e425c84
Compare
@pmakode-akamai I believe the e2e failure is relevant here - you may want to take a look at |
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 for working on this!
For whatever reason, the dragging is not nearly as smooth as the previous implementation for me. I did try the dndkit examples and they were much smoother. Could this be something wrong on our end?
develop | This PR |
---|---|
Screen.Recording.2024-10-22.at.10.44.04.AM.mov |
Screen.Recording.2024-10-22.at.10.38.40.AM.mov |
I'm also noticing that the table row is can't overflow outside of the table like it did previously when dragging. Not a blocker, but I liked how previously the row was "on top" of everything when dragging.
Hi @bnussman-akamai, I think we can definitely add a I'm encountering a similar issue to what was mentioned here when I try to add the I will check how we can add a
I agree, the |
@abailly-akamai @bnussman-akamai
update: The smoothness while dragging rows has been improved! ✅
To allow dragging over the top of current page / overflow outside of the table, we can simply add a Screen.Recording.2024-10-23.at.10.37.43.PM.movI’d like to confirm if we want to apply this header styling with noOverflow={true} for the FirewallRulesTable. Additionally, should we maintain the overflow settings for Firewall Rules Table, considering that the version in production does not have overflow? |
@pmakode-akamai @bnussman-akamai It struck me that adding I pushed a commit to:
|
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.
Great work - thanks for the contribution 👍
In production I'm able to re-order rules with the keyboard (using |
The team seems to have put great care into accessibility for this component, which is great - https://docs.dndkit.com/guides/accessibility#keyboard-support This implementation was missing the keyboard sensors, which surprise me isn't a default. Anyway, added them. You experience may differ slightly from the previous plugin tho |
packages/manager/src/features/Firewalls/FirewallDetail/Rules/FirewallRuleTable.tsx
Outdated
Show resolved
Hide resolved
}, | ||
}), | ||
useSensor(TouchSensor), | ||
useSensor(KeyboardSensor) |
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 KeyboardSensor
achieves the effect we're looking for. It moves items in the keyed direction by 25px, which can make it difficult to precisely change the place of the item. It allows moving the item left and right and also scrolls the page.
Screen.Recording.2024-10-23.at.6.47.21.PM.mov
I can't find an option within dnd-kit that accomplishes the prior behavior. My recommendation is to setup a custom key handler that calls triggerReorder
as well as e.preventDefault()
to prevent the scrolling issue.
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.
That's fair!
I can't find an option within dnd-kit that accomplishes the prior behavior.
I believe the commit underneath achieves parity with the previous behavior, while still using the kit and avoiding a custom key handler. Can you confirm?
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.
This gets closer but I'm still seeing some weird behavior when the page has vertical scrolling enabled. It's hard to describe but you can see it for yourself by Ctrl
-+
'ing in until the page overflows.
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.
@abailly-akamai @hkhalil-akamai I tried different ways and even used e.preventDefault()
to prevent window scrolling (when the browser has vertical scroll enabled) while the KeyboardSensor
is active. However, this didn't work due to how the dnd-kit
KeyboardSensor is implemented, as it adds default scrolling behavior. After extensive digging 🥲, I found that the handleKeyDown
method from the KeyboardSensor
does not allow us to override the scrolling behavior when using keyboard keys. As a result, I customized the dnd-kit library code itself to meet our requirements 😅, and some how I was able to prevent the scroll behavior when using keyboard keys ✅
Could you take a look?
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.
Great digging, this works exactly like I would expect it to! 👏🏽🎉
overflowX: 'auto', | ||
overflowY: 'hidden', |
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 looked at a couple components that had this property declared and did not see any regression. Not sure what the intent was when adding it, but since it did the opposite it's worth checking
Thank you for the changes, but I wonder if the intent was to enable a horizontal scrollbar for all tables by default, without the noOverflow
property (for smaller screens or at time when the table content tend to overflow)?
Browser window adjusted / or on smaller screens:
On Prod | On this Branch with these changes |
---|---|
If the plan is to apply overflowX: auto
to all our normal tables by default (incase), we need to ensure this doesn't affect the Firewall Rules Table. As, we want to allow row dragging over the top in this case, which won’t be possible if overflowX: auto is enabled. With some changes here; we may need to add noOverflow
property specific to the Firewalls Rules table.
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.
Yeah sorry I am working too fast on this one - I'll revert that part but keep the styling fix
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.
Great work @pmakode-akamai @abailly-akamai! 🎉
f8160db
to
275706b
Compare
@bnussman-akamai Are we good to merge this PR? thanks!! |
@pmakode-akamai have you confirmed the failing tests are unrelated? |
@abailly-akamai yea, this should be unrelated confirming all checks for these 2 specs pass locally. I think all checks should pass on re-run. |
Cloud Manager UI test results🎉 445 passing tests on test run #32 ↗︎
|
Description 📝
While working on ticket M3-8533 & PR #11109, we decided to implement/use semantic markup for the Firewall rules table to improve consistency and accessibility, rather than applying a styling band-aid to div grids to make it look like our normal tables. The
react-beautiful-dnd
library has made us rely on div(Box) grids instead of our normal tables, which complicates using semantic tables/grid layouts because of the draggable elements. Plus, this library has been deprecated (announcement: atlassian/react-beautiful-dnd#2672).To solve these problems and make better use of our normal tables, switching to
dnd-kit
(https://dndkit.com/) would be the great idea, which is more popular, supports grid layouts better, and can replacereact-beautiful-dnd
. This will help us use our semantic tables properly and fix the issues with the Firewall rules table in both dark and light modes.Changes 🔄
List any change relevant to the reviewer.
PolicyRow
react-beautiful-dnd
withdnd-kit
lib<Table />
styling fornoOverflow
propertyTarget release date 🗓️
N/A
Preview 📷
How to test 🧪
Prerequisites
Reproduction steps
Verification steps
As an Author I have considered 🤔
Check all that apply