Skip to content
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

fix(ra-ui-materialui): Fix <TabbedFormView/> to support string ids with spaces #10324

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

geobde
Copy link
Contributor

@geobde geobde commented Oct 31, 2024

Bug Fix: TabbedForm Support for IDs with Spaces

Problem:

TabbedForm fails to render tabs when the entity ID contains spaces.
This occurs because TabbedFormView compares the raw location.pathname (which contains
encoded spaces as %20) with tab paths, causing the path matching to fail.

Solution:

Fixed getDecodedPathname utility function that:

  1. Splits the pathname into segments
  2. Decodes URI components to handle %20 and other encoded characters
  3. Removes any remaining spaces
  4. Rejoins the path

This ensures consistent path matching regardless of spaces in entity IDs, allowing
TabbedForm to properly render and navigate between tabs.

Fixes #9545

@geobde geobde changed the title Fix <TabbedFormView/> to support string ids with spaces fix(ra-ui-materialui): Fix <TabbedFormView/> to support string ids with spaces Oct 31, 2024
@djhi
Copy link
Collaborator

djhi commented Nov 5, 2024

Hi and thanks for the PR! Would you mind adding a story and a test? Besides, don't we have the same issue with <TabbedShowLayout>?

@geobde
Copy link
Contributor Author

geobde commented Nov 10, 2024

Hello! No, we don't have the same issue with the TabbedShowLayout component because it doesn't use location.pathname to match the tab path.

@geobde
Copy link
Contributor Author

geobde commented Nov 10, 2024

@djhi i just added a story & unit test

@djhi djhi self-requested a review November 14, 2024 10:21
@djhi
Copy link
Collaborator

djhi commented Nov 14, 2024

I tried your PR locally and it seems it already work in v5 without the fix. Your issue mention react-admin v4 though. Can you confirm?

@geobde
Copy link
Contributor Author

geobde commented Nov 16, 2024

@djhi I’m not sure, but I just used the example app and changed the ID from 1 to "1 1", and it’s not working.

Here’s the link to the relevant code: data.tsx#L4.

@fzaninotto
Copy link
Member

I can confirm the bug exists in v5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

String Ids with spaces are not supported by TabbedForm
3 participants