@@ -170,6 +170,9 @@ function Card(props: CardProps) {
170
170
) ;
171
171
}
172
172
173
+ type ComputedProps = ReturnType < typeof useComputedProps > ;
174
+ type CommonProps = ComputedProps [ 'commonProps' ] ;
175
+
173
176
function NoteOrCard ( {
174
177
props,
175
178
setHighlightRemoved,
@@ -179,7 +182,7 @@ function NoteOrCard({
179
182
props : CardPropsWithBookAndPage ;
180
183
setHighlightRemoved : React . Dispatch < React . SetStateAction < boolean > > ;
181
184
locationFilterId : string ;
182
- computedProps : ReturnType < typeof useComputedProps > ;
185
+ computedProps : ComputedProps ;
183
186
} ) {
184
187
const {
185
188
focusCard,
@@ -219,7 +222,7 @@ function NoteOrCard({
219
222
/>
220
223
) : (
221
224
< EditCardWithOnCreate
222
- cardProps = { props as CardPropsWithBookAndPage }
225
+ cardProps = { props }
223
226
commonProps = { { ...commonProps , onRemove } }
224
227
locationFilterId = { locationFilterId }
225
228
hasUnsavedHighlight = { hasUnsavedHighlight }
@@ -230,9 +233,8 @@ function NoteOrCard({
230
233
) ;
231
234
}
232
235
233
- type ComputedProps = ReturnType < typeof useComputedProps > ;
234
236
type EditCardProps = {
235
- commonProps : object ;
237
+ commonProps : CommonProps & { onRemove : ( ) => void } ;
236
238
cardProps : CardPropsWithBookAndPage ;
237
239
locationFilterId : string ;
238
240
} & Pick < ComputedProps , 'hasUnsavedHighlight' | 'setEditing' > ;
@@ -291,12 +293,13 @@ const StyledCard = styled(Card)`
291
293
// Styling is expensive and most Cards don't need to render
292
294
function PreCard ( props : CardProps ) {
293
295
const computedProps = useComputedProps ( props ) ;
296
+ const hideUnfocusedEditCard = computedProps . annotation ? { } : { isHidden : ! props . shouldFocusCard }
294
297
295
298
if ( ! computedProps . annotation && ( ! props . isActive ) ) {
296
299
return null ;
297
300
}
298
301
return (
299
- < StyledCard { ...props } />
302
+ < StyledCard { ...{ ... props , ... hideUnfocusedEditCard } } />
300
303
) ;
301
304
}
302
305
0 commit comments