keystonejs-contrib / k6-contrib

Keyston-6 contrib
MIT License
35 stars 18 forks source link

@k6-contrib/fields-s3-images causes toast not working in admin UI #35

Closed g012 closed 2 years ago

g012 commented 2 years ago

If I add @k6-contrib/fields-s3-images as dependency, even doing nothing with it, a page in admin UI as such :

/** @jsxRuntime classic */
/** @jsx jsx */

import React, { useEffect, useMemo, useState } from 'react';
import { Box, Center, Stack, Text, jsx, useTheme } from '@keystone-ui/core';
import { PageContainer } from '@keystone-6/core/admin-ui/components';
import { Heading } from '@keystone-ui/core';
import { Button } from '@keystone-ui/button';
import { FieldLabel, TextInput } from '@keystone-ui/fields';
import { useToasts } from '@keystone-ui/toast';

export default () => {
    const { addToast } = useToasts();

    const plop = () => {
        addToast({ title: 'Successfully uploaded tasks', tone: 'positive' });
    };

    return (
        <PageContainer header={
            <Heading type="h3">
                Debug
            </Heading>
        }>
            <Button onClick={plop}>
                Test
            </Button>
        </PageContainer>
    )
}

Will cause an error stating addToast can only be used within a ToastProvider. Removing @k6-contrib/fields-s3-images as dependency fixes the error and the toast displays. This is with a fresh keystone project, so version 2. Using list-plugin is fine though, so it's specifically with s3-images.

jezzzm commented 2 years ago

there are a few other dep issues that have come about with the recent updates to keystone itself -- some semver majors there.

to circumvent for the moment you can force resolutions with yarn:

"resolutions": {
    "react": "^18",
    "@keystone-ui/fields": "^7",
    "@keystone-ui/button": "^7",
    "@keystone-ui/core": "^5",
    "@keystone-ui/pill": "^7",
    "@keystone-ui/toast": "^6"
  },

keystone they introduced built-in s3 handling but none of the sharp smarts that this package has so i prefer to stick to this.

should we still expect updates to this project @gautamsi ?

gautamsi commented 2 years ago
  info Publishing "@k6-contrib/fields-azure" at "2.0.0"
🦋  info Publishing "@k6-contrib/fields-bigint" at "2.0.0"
🦋  info Publishing "@k6-contrib/fields-dimension" at "2.0.0"
🦋  info Publishing "@k6-contrib/fields-encrypted" at "2.0.0"
🦋  info Publishing "@k6-contrib/fields-s3" at "2.0.0"
🦋  info Publishing "@k6-contrib/fields-s3-images" at "2.0.0"
🦋  info Publishing "@k6-contrib/fields-weight" at "2.0.0"
🦋  info Publishing "@k6-contrib/list-plugins" at "2.0.0"
🦋  info Publishing "@k6-contrib/session" at "2.0.0