polaris icon indicating copy to clipboard operation
polaris copied to clipboard

[IndexTable] allow ReactNode as heading title

Open sylvhama opened this issue 2 years ago • 2 comments

WHY are these changes introduced?

Fixes https://github.com/Shopify/polaris/issues/7120

The goal is to be able to pass anything to title without breaking existing implementations.

WHAT is this pull request doing?

Update typing and keys in order to be able to do something like: https://codesandbox.io/s/tooltips-examples-75cc9c?file=/App.js without triggering JS warnings or TS errors.

  • title string no id: nothing changes for this, the title will be used as a key and a warning will be triggered if they use twice the same key. The id is optional but it can still be passed (btw regarding title, string is a valid ReactNode).
  • title JSX with id: the id will be used as a key. If you omit passing the id then a TS error will trigger.
  • no title no id: TS will complain plus React will trigger the key warnings.Some people might not use TS so having a fallback empty string might help to raise awareness since it will trigger a React warning.

Screenshots of TS errors

jsx title but no id

Screen Shot 2022-09-13 at 12 01 26 PM

id present but no title

Screen Shot 2022-09-13 at 12 00 08 PM

How to 🎩

🖥 Local development instructions 🗒 General tophatting guidelines 📄 Changelog guidelines

You could re-create https://codesandbox.io/s/tooltips-examples-75cc9c?file=/App.js in your playground.

🎩 checklist

sylvhama avatar Sep 07 '22 16:09 sylvhama

/shrimpit

sylvhama avatar Sep 13 '22 21:09 sylvhama

🦐 @sylvhama this repo is not shipit integrated 😄

carolopolo avatar Sep 14 '22 14:09 carolopolo

hi hi @carolopolo! Could we ship this post rebase? We'd love to push this alongggg 👀 ♥️

ginabak avatar Sep 27 '22 15:09 ginabak