-
Notifications
You must be signed in to change notification settings - Fork 538
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
UnderlineNav doesn't update its tabs when the items change #4914
Comments
👋🏻 Thanks for reporting. For the Primer First Responder who picks this up: please investigate and add an appropriate |
Primer first responder here 👋 I did a semi-deep dive into this today. The bottom line is that the component just isn't architected to support adding or removing tabs. Supporting such behavior will involve significant refactoring work, so I've sized it at Additional detailsI was actually able to get things 90% working with a few minor changes, but the component exhibited a number of curious behaviors as a result, mostly around the calculations for remaining horizontal space. The component calculates the width of each child item and stores the widths in an array in the parent. To do this, it wraps the component in an instance of |
Thanks for investigating @camertron. @jaked can you tell us more about your use case for changing the items in |
Thanks @camertron / @lesliecdubs. We're using it in a tabbed file editor, where files can be added / removed / renamed. |
@jaked is this use case in dotcom or another production app? Can you share a little more about the business goals of the UI you're working on? More info will help us make better decisions about how to prioritize further action. Thanks! |
This is for a GitHub Next prototype called GitHub Spark. Tagging @drifkin for followup. |
Thanks. @dipree given the described use case above, what do you think about where this sits in priorities for Primer? Given this assessment, we propose it's a |
Just to add additional context that we had another issue reported - seems like it got closed due to being stale- related to the same problem and as @camertron mentioned that it is an intentional decision (some more context on the design decision) and requires refactoring. I'd be happy to do a quick spike about how much work it requires to support this if we need - just let me know 🙌🏻 |
@broccolinisoup it would be helpful if you could timebox a spike (<1hr) to determine how much work it might take to support this. I'll assign to you as a next step, but give a shout if you don't have capacity to fit this in. |
Description
If you change the items in an
UnderlineNav
, it doesn't update the tabs.In the video, I'm generating an
UnderlineNav
fromnumItems
; if I change theuseState
initializer, the whole component remounts and theUnderlineNav
tabs update; but if I changenumItems
viasetState
it causes a rerender but not a remount, and the tabs do not update.CleanShot.2024-09-03.at.14.29.18.mp4
As far as I can see, this is because the list of children is kept in React state (
responsiveProps
) that is not updated when the children change. It looks like this was fixed in #2618 but broken again in #3361.See https://github.com/jaked/primer-react-UnderlineNav-bug for a repro.
Steps to reproduce
as above
Version
v36.27.0
Browser
No response
The text was updated successfully, but these errors were encountered: