-
Notifications
You must be signed in to change notification settings - Fork 0
ERA-11237: Conditional display of event detail location markers on map #1258
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
Conversation
@@ -71,6 +71,7 @@ const LocationPicker = ({ | |||
className={`${styles.input} ${readOnly ? styles.readOnly : ''}`} | |||
disabled={disabled} | |||
id={id} | |||
onFocus={() => setLocationButtonRef.current.focus()} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For form data management, the id
must be appended to the <input>
but we forward the focusing to the button so when we programmatically focus the element by the id (like when we click a location marker) we see the location picker button being focused.
return <li | ||
className={itemClassName} | ||
data-testid="schema-form-collection-item" | ||
id={`${collectionDetails.value}.${id}`} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add an id to the collection items so we can focus them programmatically when a user clicks a location marker which has its corresponding location field inside a collection item.
@@ -131,6 +132,11 @@ const Collection = ({ | |||
setItems([...items, { id: lastAddedItemIdRef.current, isFormModalOpen: true, isFormPreviewOpen: false }]); | |||
}; | |||
|
|||
// If a location field from an item requests to focus its location marker, prefix the marker id with the collection | |||
// id and the item index. | |||
const focusLocationMarkerFromItem = (itemIndex) => (markerId) => |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Location fields inside collection items need to have prefixed ids to make them unique, otherwise several items may have the location field set and have their ids clashing, so we propagate the callbacks prefixing the ids like: collection1.2.nested-collection.1.item
. Notice that, since we decided to allow every single character in the values of a field in the EFB, there may be scenarios where this is not enough to make ids unique (a user could decide to set the value of a field like: collection.1.field
, the chances are extremely low, but its possible). We should have prohibited some characters 😅
blurLocationMarker, | ||
focusLocationMarker, | ||
updateLocationMarkers | ||
} = useLocationMarkersLayer(eventLocation, onLocationMarkerClick); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here we use the new hook, we pass the event location and the callback to focus the corresponding fields when clicking a marker, and receive the methods to focus, blur and update the markers.
}; | ||
addLocationMarkersFromFormDataRecursively(formData); | ||
|
||
updateLocationMarkers(locationMarkers); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here we update the markers every time the form data changes.
const MARKER_CONNECTING_LINES_LAYER_ID = `${LAYER_IDS.EVENT_LOCATION_MARKERS}-lines`; | ||
const MARKER_CONNECTING_OUTLINES_LAYER_ID = `${LAYER_IDS.EVENT_LOCATION_MARKERS}-outlines`; | ||
|
||
const useLocationMarkersLayer = (eventLocation, onMarkerClickCallback) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And here we have all the source / layer / map events logic to handle the new location markers. Hopefully the file is very self-explanatory.
…ease zoom level when jumping to location markers
It's not hard to do so, but honestly I have mixed feelings about this. The idea behind the current logic is very simple: When focusing our location widget, by default we focus the open popover button, which wraps the value. This adds a blue border, which is what you are referring to. Now, when clicking a button, browsers natively put the focus on them, but it's not common practice to add a border or outline to them. It's just the standard. It doesn't mean the button is not focused. That is why when we click the jump to location button the marker gets blue, because the button keeps the focus, even if the border doesn't appear. Your suggestion is to do something that is not common, and that may be confusing or irritating for users: move the from button A to button B when clicking button A. That is not an accessible practice, the expected behavior is to just keep the focus in the clicked button, even if its not being surrounded by a blue border or outline (which again, is normal with buttons, we just add the outline when they are navigated to from the keyboard). I could do it, if you really think it's worth it, I just wanted to write my thoughts. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking great! 🫡
What does this PR do?
Add location markers on the map when the user opens an event with a form that includes location fields.
How does it look
Relevant link(s)
Where / how to start reviewing (optional)
useLocationMarkersLayer
, which receives the event location and a click callback and exposes methods to update the markers, focus and blur them.SchemaForm
and its children.Any background context you want to provide(if applicable)
This feature won't work in mobile devices for two reasons: