elements icon indicating copy to clipboard operation
elements copied to clipboard

Fail gracefully when a request samples option saved in localstorage doesn't exist.

Open mpodlasin opened this issue 4 years ago • 1 comments

Screenshot 2021-08-16 at 17.25.24.png

When users choose an option in Request Samples, we save it in local storage. If however that option disappears from code (let's say we decided it's not needed anymore), this causes the docs component to crash.

We should fail gracefully in that case, preferably resetting local storage to the first available option.

To reproduce, choose an option (say JavaScript/Fetch) and then remove it from config and refresh the page.

mpodlasin avatar Aug 16 '21 15:08 mpodlasin

In RequestSamples we are using "persisted atoms" - https://github.com/stoplightio/elements/blob/main/packages/elements-core/src/components/RequestSamples/RequestSamples.tsx#L22

This is a custom wrapper - https://github.com/stoplightio/elements/blob/0eceb91e2d786d1c35d9cf632ab74c7efc1b119c/packages/elements-core/src/utils/jotai/persistAtom.ts#L4 - for a jotai library - https://github.com/pmndrs/jotai

mpodlasin avatar Oct 04 '21 10:10 mpodlasin