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

record board card creation using pending record id #9236

Closed

Conversation

ehconitin
Copy link
Contributor

);

return (
<FieldInput
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure if we want this or inlineCells to be opened in edit mode.

@charlesBochet
Copy link
Member

charlesBochet commented Jan 11, 2025

@ehconitin I've tried to test the behavior but fixing the conflicts is not completely straightforward. Could you fix them first?

Thank you!

@charlesBochet
Copy link
Member

Taking another look

@charlesBochet
Copy link
Member

Starting with the functional review:

  1. [Opportunity object] In the "Add new" mode, I cannot type in the opened Right drawer
image
  1. [Opportunity object] I cannot navigate the dropdown using arrows
image
  1. [Opportunity object] On click outside, the dropdown does not close
image
  1. [Any object] I cannot navigate dropdown using arrows
image
  1. [Any object] TextIdentifier Input is forward compared to the table header
image
  1. [Any object] Hotkey (Pressing Enter/Esc) does not work
image
  1. [Any object] Clicking outside of a pending card without having typed the name should close and not persist
image

import { RecordBoardContext } from '../contexts/RecordBoardContext';
import { recordBoardPendingRecordIdByColumnComponentFamilyState } from '../states/recordBoardPendingRecordIdByColumnComponentFamilyState';

export const useUpsertBoardOpportunityRecord = (recordBoardId: string) => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks duplicated with useUpsertBoardRecord below. I'm not fully against it if it's hard to merge them (I would prefer two clear hooks over one which is hard to maintin) but I feel we could try to merge them.

Long term, we plan to address record creation through the RightDrawer so I would not over invest on this area. The abstract reason why for "opportunity" we need to fill the "company" is that "company" would be a REQUIRED field on opportunity. Right now it's hard coded for opportunity and it's fine keeping it like this as long as we haven't introduced both required relations and creation in Right Drawer.

So I would not over engineer this and why not just making company optional in useUpsertBoardRecord for now and merge both hooks

);

const [pendingRecord] = useRecoilState(
recordBoardPendingRecordIdByColumnState(columnId),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should be a componentState

}}
>
<RecordInlineCellEditMode>
<RecordBoardCellFieldInput />
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is much better

import { useContext } from 'react';
import { useRecoilCallback } from 'recoil';

export const RecordBoardCellFieldInput = () => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would name this component differently. I feel it's RecordBoardPendingTextIdentifierFieldInput


const handleEnter: FieldInputEvent = (persistField) => {
persistField();
onUpsertRecord({
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't we call useUpsertBoardRecord here?

Looks like the main challenge:

  • if we wouldn't have the opporunity (+ company case), we only upsert the record once the name is filled (so calling useUpsertBoardRecord here), I think that's what's done on the RecordTable
  • but as we need to persist the company too, you are persisting the record sooner and only updating it here now.

I would try to call useUpsertBoardRecord (so no persist it sooner), and instead for the opportunity.company case, I would write in the recordStore { recordId: pendingRecordId, company: xxx, position: xxx } in useCreateNewBoardRecord

It should work!

@@ -166,7 +154,9 @@ export const RecordBoardColumnHeader = () => {
<LightIconButton
accent="tertiary"
Icon={IconPlus}
onClick={() => handleNewButtonClick('first', isOpportunity)}
onClick={() =>
createNewBoardRecord(columnDefinition.id, 'first')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is right

onCancel={() => createNewBoardRecord(columnId, position)}
onRecordSelected={(company) => {
if (isDefined(company)) {
upsertBoardOpportunityRecord(columnId, company);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so I would not upsert here but createNewBoardRecord + write in recordStore instead.

Copy link
Member

@charlesBochet charlesBochet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is much better. I have left one important comment:

  • on Add New click, let's not upsert but always call createNewBoardRecord (set pendingRecordId + write in record store if necessary)
  • on TextIdentfier submit, lets call upsert

@charlesBochet
Copy link
Member

@ehconitin I'm closing the PR to keep the history clean, I'm happy to re-review it once ready / help on this one if needed :)
Please re-open once ready

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

Successfully merging this pull request may close these issues.

2 participants