Skip to content
Open
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions src/app/components/Modal/__snapshots__/Modal.spec.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ exports[`Modal matches snapshot 1`] = `
-ms-flex-align: center;
align-items: center;
margin: 0;
padding: 1.5rem 0;
}

.c6 {
Expand Down Expand Up @@ -263,7 +262,6 @@ exports[`Modal matches snapshot with children 1`] = `
-ms-flex-align: center;
align-items: center;
margin: 0;
padding: 1.5rem 0;
}

.c6 {
Expand Down
1 change: 0 additions & 1 deletion src/app/components/Modal/styles.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ export const Heading = styled.h1`
display: flex;
align-items: center;
margin: 0;
padding: ${modalPadding * 0.5}rem 0;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Padding was doubled in the dialog title bar

`;

// tslint:disable-next-line:variable-name
Expand Down
4 changes: 4 additions & 0 deletions src/app/content/__snapshots__/routes.spec.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,10 @@ Array [
.c4 .highlight {
position: relative;
z-index: 1;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}

.c4 .MathJax_Display .highlight,
Expand Down
1 change: 1 addition & 0 deletions src/app/content/components/Page/PageContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ export default styled(MainContent)`
.highlight {
position: relative;
z-index: 1;
user-select: none;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Prevent text selection in highlights, in particular by double-clicking, but overlapping highlights aren't allowed anyway, so this prevents error messages.

}

/* stylelint-disable selector-class-pattern */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -711,6 +711,10 @@ Array [
.c74 .highlight {
position: relative;
z-index: 1;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}

.c74 .MathJax_Display .highlight,
Expand Down Expand Up @@ -8072,6 +8076,10 @@ Array [
.c74 .highlight {
position: relative;
z-index: 1;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}

.c74 .MathJax_Display .highlight,
Expand Down
13 changes: 8 additions & 5 deletions src/app/content/highlights/components/Card.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,9 @@ function Card(props: CardProps) {
);
}

type ComputedProps = ReturnType<typeof useComputedProps>;
type CommonProps = ComputedProps['commonProps'];

function NoteOrCard({
props,
setHighlightRemoved,
Expand All @@ -179,7 +182,7 @@ function NoteOrCard({
props: CardPropsWithBookAndPage;
setHighlightRemoved: React.Dispatch<React.SetStateAction<boolean>>;
locationFilterId: string;
computedProps: ReturnType<typeof useComputedProps>;
computedProps: ComputedProps;
}) {
const {
focusCard,
Expand Down Expand Up @@ -219,7 +222,7 @@ function NoteOrCard({
/>
) : (
<EditCardWithOnCreate
cardProps={props as CardPropsWithBookAndPage}
cardProps={props}
commonProps={{ ...commonProps, onRemove }}
locationFilterId={locationFilterId}
hasUnsavedHighlight={hasUnsavedHighlight}
Expand All @@ -230,9 +233,8 @@ function NoteOrCard({
);
}

type ComputedProps = ReturnType<typeof useComputedProps>;
type EditCardProps = {
commonProps: object;
commonProps: CommonProps & {onRemove: () => void};
cardProps: CardPropsWithBookAndPage;
locationFilterId: string;
} & Pick<ComputedProps, 'hasUnsavedHighlight' | 'setEditing'>;
Expand Down Expand Up @@ -291,12 +293,13 @@ const StyledCard = styled(Card)`
// Styling is expensive and most Cards don't need to render
function PreCard(props: CardProps) {
const computedProps = useComputedProps(props);
const hideUnfocusedEditCard = computedProps.annotation ? {} : {isHidden: !props.shouldFocusCard};
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Edit card now only appears when making edits to the highlight/note


if (!computedProps.annotation && (!props.isActive)) {
return null;
}
return (
<StyledCard {...props} />
<StyledCard {...{...props, ...hideUnfocusedEditCard}} />
);
}

Expand Down
18 changes: 14 additions & 4 deletions src/app/content/highlights/components/CardWrapper.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -303,9 +303,11 @@ describe('CardWrapper', () => {
const highlight2 = createMockHighlight('id2');
const highlightElement1 = document.createElement('span');
const highlightElement2 = document.createElement('span');
highlight1.elements.push(highlightElement1);
highlight2.elements.push(highlightElement2);
container.appendChild(highlightElement1);
container.appendChild(highlightElement2);
const component = renderer.create(
renderer.create(
<Provider store={store}>
<CardWrapper
container={container}
Expand All @@ -314,7 +316,12 @@ describe('CardWrapper', () => {
</Provider>
);

const cards = component.root.findAllByType(Card);
renderer.act(() => {
store.dispatch(focusHighlight(highlight1.id));
});

// These tests get code coverage but do not update the highlight structures
// so that we can see that they worked as expected

// Expect cards to be hidden
renderer.act(() => {
Expand Down Expand Up @@ -343,8 +350,11 @@ describe('CardWrapper', () => {
});
});

expect(cards[0].props.isHidden).toBe(false);
expect(cards[1].props.isHidden).toBe(false);
// Set focusedHighlight, and do double=click
renderer.act(() => {
highlightElement1.dispatchEvent(new Event('focus', { bubbles: true }));
highlightElement1.dispatchEvent(new Event('dblclick', { bubbles: true }));
});
});

it(
Expand Down
Loading
Loading