Skip to content

Commit

Permalink
Improve aria-label for ad articles
Browse files Browse the repository at this point in the history
  • Loading branch information
otenav committed Apr 27, 2022
1 parent 187e552 commit a7332e1
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion src/views/search/searchResults/SearchResultsItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,31 @@ import SearchResultsItemDetails from "./SearchResultsItemDetails";
import FavouritesButton from "../../favourites/FavouritesButton";
import "./SearchResultsItem.less";
import getEmployer from "../../../../server/common/getEmployer";
import getWorkLocation from "../../../../server/common/getWorkLocation";

function toLabel(stilling) {
const fragments = [];
const location = getWorkLocation(stilling.properties.location, stilling.locationList);
const employer = getEmployer(stilling);
if(stilling.title) {
fragments.push(stilling.title);
}
if (stilling.properties.jobtitle && stilling.title !== stilling.properties.jobtitle) {
fragments.push(stilling.properties.jobtitle);
}
if(employer) {
fragments.push(employer);
}
if(location) {
fragments.push(location);
}
return fragments.join(". ");
}

export default function SearchResultItem({ stilling }) {
const label = toLabel(stilling);
return (
<article aria-label={`${stilling.title}, ${getEmployer(stilling)}`} className="SearchResultItem">
<article aria-label={label} className="SearchResultItem">
<SearchResultsItemDetails stilling={stilling} />
<FavouritesButton
showText={false}
Expand Down

0 comments on commit a7332e1

Please sign in to comment.