Skip to content

Core 20 highlight edit navigation #2558

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

Open
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

RoyEJohnson
Copy link
Contributor

@RoyEJohnson RoyEJohnson commented Aug 13, 2025

@TomWoodward TomWoodward temporarily deployed to rex-web-core-20-highlig-7tndkq August 13, 2025 23:32 Inactive
@RoyEJohnson RoyEJohnson force-pushed the core-20-highlight-edit-navigation branch from f4806f7 to 4a38c4a Compare August 13, 2025 23:32
@TomWoodward TomWoodward temporarily deployed to rex-web-core-20-highlig-7tndkq August 13, 2025 23:32 Inactive
@TomWoodward TomWoodward temporarily deployed to rex-web-core-20-highlig-7tndkq August 15, 2025 16:08 Inactive
@RoyEJohnson RoyEJohnson force-pushed the core-20-highlight-edit-navigation branch from 1683277 to 9f6495c Compare August 15, 2025 17:09
@TomWoodward TomWoodward temporarily deployed to rex-web-core-20-highlig-7tndkq August 15, 2025 17:09 Inactive
@TomWoodward TomWoodward temporarily deployed to rex-web-core-20-highlig-7tndkq August 18, 2025 21:47 Inactive
@RoyEJohnson RoyEJohnson force-pushed the core-20-highlight-edit-navigation branch from 65e322d to 51bd861 Compare August 18, 2025 21:50
@TomWoodward TomWoodward temporarily deployed to rex-web-core-20-highlig-7tndkq August 18, 2025 21:50 Inactive
@RoyEJohnson RoyEJohnson force-pushed the core-20-highlight-edit-navigation branch from 51bd861 to 600cdff Compare August 18, 2025 22:06
@TomWoodward TomWoodward temporarily deployed to rex-web-core-20-highlig-7tndkq August 18, 2025 22:07 Inactive
@RoyEJohnson RoyEJohnson marked this pull request as ready for review August 18, 2025 22:10
@RoyEJohnson RoyEJohnson requested a review from a team as a code owner August 18, 2025 22:10
@RoyEJohnson RoyEJohnson requested a review from jivey August 18, 2025 22:10
@@ -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

@@ -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.

@@ -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

return [cardsHeights, onHeightChange] as const;
}

function rangeString({startOffset, endOffset}: Highlight['range']) {
Copy link
Contributor Author

@RoyEJohnson RoyEJohnson Aug 18, 2025

Choose a reason for hiding this comment

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

Functional changes are here through the end of useFocusedHighlight. There's a section below where most of the code was extracted to make the function, and replaced with a call to useFocusedHighlight. It's more obvious what I did if you look at the individual commit.

@@ -454,24 +454,22 @@ function useOnColorChange(props: EditCardProps) {
}

function useSaveAnnotation(
props: EditCardProps,
{ data, pageId, locationFilterId, highlight, onCancel }: EditCardProps,
Copy link
Contributor Author

@RoyEJohnson RoyEJohnson Aug 18, 2025

Choose a reason for hiding this comment

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

Just a bit of revising to props handling

@@ -94,59 +94,63 @@ interface Props {
loggedOut: boolean;
}

function useCloseAndTrack(closeFn: () => void) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Some refactoring for clarity.

@@ -142,13 +142,11 @@ export const onFocusInOrOutHandler = (
};

export const useFocusLost = (ref: React.RefObject<HTMLElement>, isEnabled: boolean, cb: () => void) => {
// eslint-disable-next-line react-hooks/exhaustive-deps
React.useEffect(onFocusInOrOutHandler(ref, isEnabled, cb, 'focusout'), [ref, isEnabled, cb]);
React.useEffect(() => onFocusInOrOutHandler(ref, isEnabled, cb, 'focusout')(), [ref, isEnabled, cb]);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

useEffect prefers to have an anonymous function, and this saves an eslint-disable comment

}
} else {
target = event.target;
}
const highlight = highlights.find(h =>
h.elements && h.elements.some(el =>
h.elements && (h.elements as Element[]).some(el =>
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This cast is better than using any below.

@TomWoodward TomWoodward temporarily deployed to rex-web-core-20-highlig-7tndkq August 20, 2025 16:06 Inactive
@TomWoodward TomWoodward temporarily deployed to rex-web-core-20-highlig-7tndkq August 20, 2025 19:07 Inactive
Copy link
Member

@jivey jivey left a comment

Choose a reason for hiding this comment

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

Changes seem good, but after using it, I'm worried the hidden highlight popup won't be discoverable enough. But we can get some feedback using the deployed env.

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

Successfully merging this pull request may close these issues.

3 participants